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.012';
4 8     8   58539 use strict;
  8         24  
  8         198  
5 8     8   33 use warnings;
  8         15  
  8         176  
6 8     8   35 use Carp qw(croak);
  8         13  
  8         388  
7 8     8   436 use Log::Any qw();
  8         8453  
  8         127  
8              
9 8     8   45 use base qw(Exporter);
  8         12  
  8         1371  
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 172     172 1 236 my ($class, $method_name) = @_;
20 172         629 return $class->can($method_name);
21             }
22              
23             sub set_new_method {
24 174     174 1 277 my ($class, $method_name, $new_method) = @_;
25              
26 8     8   56 no warnings 'redefine';
  8         14  
  8         269  
27 8     8   37 no strict 'refs'; ## no critic (ProhibitNoStrict)
  8         18  
  8         1066  
28 174         201 *{ $class . '::' . $method_name } = $new_method;
  174         567  
29             }
30              
31             sub get_class_name {
32 12     12 1 515 my ($name) = @_;
33              
34 12 100       73 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 16 my ($class) = @_;
40              
41 7         22 return ( Log::Any->logging_methods, Log::Any->log_level_aliases );
42             }
43              
44             1;
45              
46             __END__