line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Log::ger::Output::Perl; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $DATE = '2017-07-24'; # DATE |
4
|
|
|
|
|
|
|
our $VERSION = '0.001'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
4883
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
31
|
|
7
|
1
|
|
|
1
|
|
8
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
29
|
|
8
|
1
|
|
|
1
|
|
8
|
use Log::ger::Util (); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
321
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub get_hooks { |
11
|
1
|
|
|
1
|
0
|
19
|
my %conf = @_; |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
50
|
|
|
7
|
my $action = delete($conf{action}) || { |
14
|
|
|
|
|
|
|
warn => 'warn', |
15
|
|
|
|
|
|
|
error => 'warn', |
16
|
|
|
|
|
|
|
fatal => 'die', |
17
|
|
|
|
|
|
|
}; |
18
|
1
|
50
|
|
|
|
6
|
keys %conf and die "Unknown configuration: ".join(", ", sort keys %conf); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
return { |
21
|
|
|
|
|
|
|
create_logml_routine => [ |
22
|
|
|
|
|
|
|
__PACKAGE__, 50, |
23
|
|
|
|
|
|
|
sub { |
24
|
1
|
|
|
1
|
|
547
|
my %args = @_; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my $logger = sub { |
27
|
6
|
|
|
|
|
7989
|
my $ctx = shift; |
28
|
6
|
|
|
|
|
16
|
my $lvl = shift; |
29
|
6
|
50
|
|
|
|
25
|
if (my $act = |
30
|
|
|
|
|
|
|
$action->{Log::ger::Util::string_level($lvl)}) { |
31
|
6
|
100
|
|
|
|
193
|
if ($act eq 'warn') { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
32
|
1
|
|
|
|
|
20
|
warn @_; |
33
|
|
|
|
|
|
|
} elsif ($act eq 'carp') { |
34
|
1
|
|
|
|
|
8
|
require Carp; |
35
|
1
|
|
|
|
|
20
|
goto &Carp::carp; |
36
|
|
|
|
|
|
|
} elsif ($act eq 'cluck') { |
37
|
1
|
|
|
|
|
8
|
require Carp; |
38
|
1
|
|
|
|
|
16
|
goto &Carp::cluck; |
39
|
|
|
|
|
|
|
} elsif ($act eq 'croak') { |
40
|
1
|
|
|
|
|
8
|
require Carp; |
41
|
1
|
|
|
|
|
16
|
goto &Carp::croak; |
42
|
|
|
|
|
|
|
} elsif ($act eq 'confess') { |
43
|
1
|
|
|
|
|
8
|
require Carp; |
44
|
1
|
|
|
|
|
15
|
goto &Carp::confess; |
45
|
|
|
|
|
|
|
} else { |
46
|
|
|
|
|
|
|
# die is the default action if unknown |
47
|
1
|
|
|
|
|
13
|
die @_; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
} |
50
|
1
|
|
|
|
|
8
|
}; |
51
|
1
|
|
|
|
|
5
|
[$logger]; |
52
|
1
|
|
|
|
|
10
|
}], |
53
|
|
|
|
|
|
|
}; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1; |
57
|
|
|
|
|
|
|
# ABSTRACT: Log to Perl's standard facility (warn, die, etc) |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
__END__ |