blib/lib/POE/Component/Log4perl.pm

filter: Statementstmt 37.7% 20 / 53 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 35.2% 6 / 17 Podpod 0.0% 0 / 4 totaltotal 32.1% 26 / 81 CC 4 SCAR 12.8
CC
4
Cov
34%
start_logger
12.0
poe_logger
6.0
spawn
2.0
CRAP 3.6
↑ Summary
1 package POE::Component::Log4perl;
2  
3 2 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 ▶use POE;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Log::Log4perl;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Log::Log4perl::Level;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 # ------------------------------------------------------------------------
12  
13 2 our $VERSION = '0.03';
14 2 our $level = $INFO;
15  
16 # ------------------------------------------------------------------------
17  
18 0 ▶sub spawn {
Subroutine spawn: not called CC=1 SCAR=6.9
Pod undocumented
19 0 my $class = shift;
20  
21 POE::Session->create(
22 inline_states => {
23 _start => \&start_logger,
24 _stop => \&stop_logger,
25 0 ▶ info => sub { local $level = $INFO; poe_logger(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
26 0 ▶ debug => sub { local $level = $DEBUG; poe_logger(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
27 0 ▶ warn => sub { local $level = $WARN; poe_logger(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
28 0 ▶ error => sub { local $level = $ERROR; poe_logger(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
29 0 ▶ fatal => sub { local $level = $FATAL; poe_logger(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
30 0 ▶ trace => sub { local $level = $TRACE; poe_logger(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
31 0 ▶ category => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
32 0 my ($heap, $arg0) = @_[HEAP,ARG0];
33 0 $heap->{_category} = $arg0;
34 },
35 },
36 0 args => [@_ ],
37 );
38  
39 }
40  
41 0 ▶sub start_logger {
Subroutine start_logger: not called CC=3 SCAR=24.8
Pod undocumented
42 0 my ($kernel, $heap, %args) = @_[KERNEL, HEAP, ARG0 .. $#_];
43  
44 0 Log::Log4perl::init_once($args{ConfigFile});
45 0 $Log::Log4perl::caller_depth = 1;
46 0 ▶ *{main::get_logfile} = $args{GetLogfile} if (defined($args{GetLogfile}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $args{"GetLogfile"} 0 0 0
47  
48 0 ▶ $heap->{_alias} = $args{Alias} || 'logger';
Condition0%0/2
$args{'Alias'} || 'logger'
l!l
00
MC/DC0%0/1
$args{'Alias'} || 'logger'
$args{'Alias'}
Truth table0%0/2
A
A= $args{'Alias'}
Aresult
11
00
49 0 $heap->{_category} = $args{Category};
50  
51 0 $kernel->alias_set($args{Alias});
52
53 }
54  
55 0 ▶sub stop_logger {
Subroutine stop_logger: not called CC=1 SCAR=6.9
Pod undocumented
56 0 my ($kernel, $heap) = @_[KERNEL, HEAP];
57  
58 0 $kernel->alias_remove($heap->{_alias});
59 0 delete $heap->{_alias};
60  
61 }
62  
63 0 ▶sub poe_logger {
Subroutine poe_logger: not called CC=2 SCAR=17.9
Pod undocumented
64 0 my ($heap, $arg0, @args) = @_[HEAP, ARG0, ARG1 .. $#_];
65  
66 0 my $message;
67 0 my $log = Log::Log4perl->get_logger($heap->{_category});
68  
69 0 ▶ if (ref($arg0)) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $arg0) { } 0 0 0
70  
71 0 $log->log(%$arg0);
72  
73 } else {
74  
75 0 $message = join("", $arg0, @args);
76 0 $log->log($level, $message);
77  
78 }
79  
80 }
81  
82 2 1;
83  
84 __END__
↑ Summary