| 1 | #ABSTRACT: Logging role | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | package HiD::Role::DoesLogging; | ||||||||||||||||||||||||||||
| 4 | 8 | $HiD::Role::DoesLogging::VERSION = '1.5'; | |||||||||||||||||||||||||||
| 5 | 8 | ▶ | use Moose::Role; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 8 | ▶ | use Log::Log4perl; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 8 | requires 'get_config'; | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | has logger_config => ( | ||||||||||||||||||||||||||||
| 13 | is => 'ro' , | ||||||||||||||||||||||||||||
| 14 | isa => 'HashRef', | ||||||||||||||||||||||||||||
| 15 | lazy => 1 , | ||||||||||||||||||||||||||||
| 16 | default => sub { | ||||||||||||||||||||||||||||
| 17 | 18 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 18 | 18 | my $config = $self->get_config('logger_config'); | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 18 | ▶ | return $config | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$config and %$config
MC/DC50%1/2
$config and %$config
$config
%$config
Truth table66%2/3
A and B
A= $configB= %$config
| |||||||||||||||||||||||||||||
| 21 | if ( $config && %$config ); | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | return { | ||||||||||||||||||||||||||||
| 24 | 4 | 'log4perl.logger' => 'WARN, Screen' , | |||||||||||||||||||||||||||
| 25 | 'log4perl.appender.Screen' => 'Log::Log4perl::Appender::Screen', | ||||||||||||||||||||||||||||
| 26 | 'log4perl.appender.Screen.layout' => 'PatternLayout' , | ||||||||||||||||||||||||||||
| 27 | 'log4perl.appender.Screen.layout.ConversionPattern' => '[%d] %5p %m%n' , | ||||||||||||||||||||||||||||
| 28 | }; | ||||||||||||||||||||||||||||
| 29 | }, | ||||||||||||||||||||||||||||
| 30 | 8 | ); | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 8 | has logger => ( | |||||||||||||||||||||||||||
| 34 | is => 'ro' , | ||||||||||||||||||||||||||||
| 35 | isa => 'Log::Log4perl::Logger', | ||||||||||||||||||||||||||||
| 36 | lazy => 1 , | ||||||||||||||||||||||||||||
| 37 | builder => '_build_logger' , | ||||||||||||||||||||||||||||
| 38 | handles => { | ||||||||||||||||||||||||||||
| 39 | DEBUG => 'debug' , | ||||||||||||||||||||||||||||
| 40 | WARN => 'warn' , | ||||||||||||||||||||||||||||
| 41 | INFO => 'info' , | ||||||||||||||||||||||||||||
| 42 | ERROR => 'error' , | ||||||||||||||||||||||||||||
| 43 | FATAL => 'fatal' , | ||||||||||||||||||||||||||||
| 44 | LOGWARN => 'logwarn' , | ||||||||||||||||||||||||||||
| 45 | }, | ||||||||||||||||||||||||||||
| 46 | ); | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | sub _build_logger { | ||||||||||||||||||||||||||||
| 49 | 18 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_build_logger: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 18 | Log::Log4perl->init( $self->logger_config ); | |||||||||||||||||||||||||||
| 52 | 18 | Log::Log4perl->get_logger(); | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 8 | ▶ | no Moose::Role; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 56 | 8 | 1; | |||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | __END__ | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | =pod | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | =encoding utf-8 | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | =head1 NAME | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | HiD::Role::DoesLogging - Logging role | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | =head1 ATTRIBUTES | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | =head2 logger_config | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | Configuration for logging. Defaults to: | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | log4perl.logger = DEBUG, Screen | ||||||||||||||||||||||||||||
| 75 | log4perl.appender.Screen = Log::Log4perl::Appender::Screen | ||||||||||||||||||||||||||||
| 76 | log4perl.appender.Screen.layout = PatternLayout | ||||||||||||||||||||||||||||
| 77 | log4perl.appender.Screen.layout.ConversionPattern = [%d] %5p %m%n | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | =head2 logger | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | Log4perl object for logging. Handles: | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | =over | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | =item * DEBUG | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | =item * WARN | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | =item * INFO | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | =item * ERROR | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | =item * FATAL | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | =back | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | =head1 VERSION | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | version 1.5 | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | John SJ Anderson <genehack@genehack.org> | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | This software is copyright (c) 2014 by John SJ Anderson. | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 110 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | =cut | ||||||||||||||||||||||||||||