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.007';
4 3     3   15625 use strict;
  3         6  
  3         67  
5 3     3   13 use warnings;
  3         6  
  3         65  
6 3     3   12 use Carp qw(croak);
  3         6  
  3         138  
7 3     3   348 use Log::Any qw();
  3         7926  
  3         52  
8              
9 3     3   712 use base qw(Exporter);
  3         6  
  3         326  
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 117     117 1 201 my ($class, $method_name) = @_;
20 117         456 return $class->can($method_name);
21             }
22              
23             sub set_new_method {
24 116     116 1 217 my ($class, $method_name, $new_method) = @_;
25              
26 3     3   17 no warnings 'redefine';
  3         5  
  3         95  
27 3     3   14 no strict 'refs'; ## no critic (ProhibitNoStrict)
  3         5  
  3         293  
28 116         151 *{ $class . '::' . $method_name } = $new_method;
  116         407  
29             }
30              
31             sub get_class_name {
32 7     7 1 167 my ($name) = @_;
33              
34 7 100       43 return substr($name, 0, 1) eq '+' ? substr($name, 1)
35             : 'Log::Any::Plugin::' . $name;
36             }
37              
38             sub all_logging_methods {
39 6     6 1 10 my ($class) = @_;
40              
41 6         20 return ( Log::Any->logging_methods, Log::Any->log_level_aliases );
42             }
43              
44             1;
45              
46             __END__