Saftpresse/Log4perl.pm

filter: Statementstmt 44.4% 16 / 36 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 66.6% 4 / 6 Podpod 0.0% 0 / 2 totaltotal 35.0% 20 / 57 SCAR 27.9
CC
6
Cov
34%
init
42.0
level
2.0
BEGIN
1.0
CRAP 16.3
« Saftpresse/PluginContainer.pm ↑ Summary Saftpresse/Plugin/SyslogFile.pm »
1 package Log::Saftpresse::Log4perl;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 # ABSTRACT: logging for Log::Saftpresse
7 1 our $VERSION = '1.5'; # VERSION
8  
9 1 ▶use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Log::Log4perl qw(:levels);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 our @ISA = ('Exporter');
13  
14 1 our $log;
15 1 our @EXPORT = qw( $log );
16  
17 sub init {
18 0 ▶ my ( $class, $level, $file ) = @_;
Subroutine init: not called CC=6 SCAR=37.4
Pod undocumented
19 0 my $layout = 'Log::Log4perl::Layout::SimpleLayout';
20  
21 0 ▶ if( defined $file && $file eq 'syslog' ) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $file and $file eq 'syslog') { } 0 0 0
elsif (defined $file) { } 0 0 0
Condition0%0/3
defined $file and $file eq "syslog"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $file and $file eq "syslog"
defined $file $file eq "syslog"
Truth table0%0/3
A and B
A= defined $fileB= $file eq "syslog"
ABresult
0X0
100
111
22 0 Log::Log4perl->init(\ qq{
23 log4perl.rootLogger = $level, Syslog
24 log4perl.appender.Syslog = Log::Dispatch::Syslog
25 log4perl.appender.Syslog.min_level = debug
26 log4perl.appender.Syslog.ident = saftpresse
27 log4perl.appender.Syslog.facility = daemon
28 log4perl.appender.Syslog.layout = $layout
29 });
30 } elsif( defined $file ) {
31 0 Log::Log4perl->init(\ qq{
32 log4perl.rootLogger = $level, File
33 log4perl.appender.File = Log::Log4perl::Appender::File
34 log4perl.appender.File.filename = $file
35 log4perl.appender.FileAppndr1.layout = $layout
36 });
37 } else {
38 0 my $appender = 'Log::Log4perl::Appender::ScreenColoredLevels';
39 0 my $colored = 1;
40 0 eval { require Log::Log4perl::Appender::ScreenColoredLevels; };
41 0 ▶ if( $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
42 0 $appender = 'Log::Log4perl::Appender::Screen';
43 }
44 0 Log::Log4perl->init(\ qq{
45 log4perl.rootLogger = $level, Screen
46 log4perl.appender.Screen = $appender
47 log4perl.appender.Screen.stderr = 0
48 log4perl.appender.Screen.layout = $layout
49 });
50 0 ▶ if( ! $colored ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($colored) 0 0 0
51 0 $log->debug('disabled colored logging. (install Log::Log4perl::Appender::ScreenColoredLevels)');
52 }
53 }
54  
55 0 $log = Log::Log4perl::get_logger;
56 0 $log->info('initialized logging with level '.$level);
57 }
58  
59 sub level {
60 0 ▶ my ( $class, $level ) = @_;
Subroutine level: not called CC=1 SCAR=6.9
Pod undocumented
61 0 $log->level( $OFF );
62 0 $log->more_logging( $level );
63 0 return;
64 }
65  
66 __END__
67  
68 =pod
69  
70 =encoding UTF-8
71  
72 =head1 NAME
73  
74 Log::Saftpresse::Log4perl - logging for Log::Saftpresse
75  
76 =head1 VERSION
77  
78 version 1.5
79  
80 =head1 AUTHOR
81  
82 Markus Benning <ich@markusbenning.de>
83  
84 =head1 COPYRIGHT AND LICENSE
85  
86 This software is Copyright (c) 1998 by James S. Seymour, 2015 by Markus Benning.
87  
88 This is free software, licensed under:
89  
90 The GNU General Public License, Version 2, June 1991
91  
92 =cut
« Saftpresse/PluginContainer.pm ↑ Summary Saftpresse/Plugin/SyslogFile.pm »