line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Log::Saftpresse::Log4perl; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
27
|
|
4
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
37
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: logging for Log::Saftpresse |
7
|
|
|
|
|
|
|
our $VERSION = '1.5'; # VERSION |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
3
|
use Exporter; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
38
|
|
10
|
1
|
|
|
1
|
|
777
|
use Log::Log4perl qw(:levels); |
|
1
|
|
|
|
|
34365
|
|
|
1
|
|
|
|
|
5
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @ISA = ('Exporter'); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $log; |
15
|
|
|
|
|
|
|
our @EXPORT = qw( $log ); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub init { |
18
|
0
|
|
|
0
|
0
|
|
my ( $class, $level, $file ) = @_; |
19
|
0
|
|
|
|
|
|
my $layout = 'Log::Log4perl::Layout::SimpleLayout'; |
20
|
|
|
|
|
|
|
|
21
|
0
|
0
|
0
|
|
|
|
if( defined $file && $file eq 'syslog' ) { |
|
|
0
|
|
|
|
|
|
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; }; |
|
0
|
|
|
|
|
|
|
41
|
0
|
0
|
|
|
|
|
if( $@ ) { |
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
|
0
|
|
|
|
|
if( ! $colored ) { |
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
|
|
|
0
|
0
|
|
my ( $class, $level ) = @_; |
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 |