File Coverage

blib/lib/Log/Any/Plugin/Util.pm
Criterion Covered Total %
statement 30 30 100.0
branch 2 2 100.0
condition n/a
subroutine 11 11 100.0
pod 4 4 100.0
total 47 47 100.0


line stmt bran cond sub pod time code
1             package Log::Any::Plugin::Util;
2             # ABSTRACT: Utilities for Log::Any::Plugin classes
3             $Log::Any::Plugin::Util::VERSION = '0.011';
4 7     7   59122 use strict;
  7         22  
  7         187  
5 7     7   30 use warnings;
  7         11  
  7         160  
6 7     7   55 use Carp qw(croak);
  7         22  
  7         307  
7 7     7   460 use Log::Any qw();
  7         8644  
  7         121  
8              
9 7     7   30 use base qw(Exporter);
  7         12  
  7         1315  
10              
11             our @EXPORT_OK = qw(
12             get_old_method
13             set_new_method
14             get_class_name
15             all_logging_methods
16             );
17              
18             sub get_old_method {
19 163     163 1 222 my ($class, $method_name) = @_;
20 163         582 return $class->can($method_name);
21             }
22              
23             sub set_new_method {
24 162     162 1 294 my ($class, $method_name, $new_method) = @_;
25              
26 7     7   50 no warnings 'redefine';
  7         12  
  7         226  
27 7     7   31 no strict 'refs'; ## no critic (ProhibitNoStrict)
  7         14  
  7         908  
28 162         171 *{ $class . '::' . $method_name } = $new_method;
  162         552  
29             }
30              
31             sub get_class_name {
32 11     11 1 525 my ($name) = @_;
33              
34 11 100       63 return substr($name, 0, 1) eq '+' ? substr($name, 1)
35             : 'Log::Any::Plugin::' . $name;
36             }
37              
38             sub all_logging_methods {
39 7     7 1 13 my ($class) = @_;
40              
41 7         23 return ( Log::Any->logging_methods, Log::Any->log_level_aliases );
42             }
43              
44             1;
45              
46             __END__