| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Catalyst::Plugin::Log::Handler; |
|
2
|
2
|
|
|
2
|
|
54678
|
use strict; |
|
|
2
|
|
|
|
|
8
|
|
|
|
2
|
|
|
|
|
90
|
|
|
3
|
2
|
|
|
2
|
|
14
|
use warnings; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
108
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Catalyst::Plugin::Log::Handler - Catalyst Plugin for Log::Handler |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 VERSION |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Version 0.08 |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=cut |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = '0.08'; |
|
16
|
|
|
|
|
|
|
|
|
17
|
2
|
|
|
2
|
|
2242
|
use MRO::Compat; |
|
|
2
|
|
|
|
|
17043
|
|
|
|
2
|
|
|
|
|
221
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub setup { |
|
20
|
1
|
|
|
1
|
0
|
252786
|
my $c = shift; |
|
21
|
|
|
|
|
|
|
|
|
22
|
1
|
|
50
|
|
|
5
|
my $config = $c->config->{'Log::Handler'} || {}; |
|
23
|
|
|
|
|
|
|
|
|
24
|
1
|
|
|
|
|
21
|
$c->log((__PACKAGE__ . '::Backend')->new($config)); |
|
25
|
|
|
|
|
|
|
|
|
26
|
1
|
|
|
|
|
18
|
return $c->maybe::next::method(@_); |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
package Catalyst::Plugin::Log::Handler::Backend; |
|
31
|
2
|
|
|
2
|
|
22
|
use strict; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
61
|
|
|
32
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
|
2
|
|
|
|
|
14
|
|
|
|
2
|
|
|
|
|
73
|
|
|
33
|
2
|
|
|
2
|
|
11
|
use base qw(Class::Accessor::Fast); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
2024
|
|
|
34
|
2
|
|
|
2
|
|
11876
|
use Log::Handler 0.63; |
|
|
2
|
|
|
|
|
194424
|
|
|
|
2
|
|
|
|
|
20
|
|
|
35
|
2
|
|
|
2
|
|
81
|
use MRO::Compat; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
24
|
|
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw(handler)); |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
my %cat_to_handler_level = ( |
|
40
|
|
|
|
|
|
|
debug => 'debug', |
|
41
|
|
|
|
|
|
|
info => 'info', |
|
42
|
|
|
|
|
|
|
warn => 'warning', |
|
43
|
|
|
|
|
|
|
error => 'error', |
|
44
|
|
|
|
|
|
|
fatal => 'emergency', |
|
45
|
|
|
|
|
|
|
); |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
{ |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
while (my ($catlevel, $handlerlevel) = each %cat_to_handler_level) { |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my $logsub = sub { |
|
52
|
5
|
|
|
5
|
|
2082
|
my $self = shift; |
|
53
|
|
|
|
|
|
|
|
|
54
|
5
|
|
|
|
|
20
|
$self->handler->$handlerlevel(@_); |
|
55
|
|
|
|
|
|
|
}; |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
my $handlerfunc = "is_$handlerlevel"; |
|
58
|
|
|
|
|
|
|
my $testsub = sub { |
|
59
|
5
|
|
|
5
|
|
7767
|
my $self = shift; |
|
60
|
|
|
|
|
|
|
|
|
61
|
5
|
|
|
|
|
20
|
$self->handler->$handlerfunc(); |
|
62
|
|
|
|
|
|
|
}; |
|
63
|
|
|
|
|
|
|
|
|
64
|
2
|
|
|
2
|
|
393
|
no strict 'refs'; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
398
|
|
|
65
|
|
|
|
|
|
|
*{$catlevel} = $logsub; |
|
66
|
|
|
|
|
|
|
*{"is_$catlevel"} = $testsub; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub new { |
|
71
|
1
|
|
|
1
|
|
3
|
my $class = shift; |
|
72
|
1
|
|
|
|
|
9
|
my $self = $class->next::method(); |
|
73
|
|
|
|
|
|
|
|
|
74
|
1
|
|
|
|
|
50
|
my ($config) = @_; |
|
75
|
|
|
|
|
|
|
|
|
76
|
1
|
50
|
|
|
|
8
|
unless (exists $config->{filename}) { |
|
77
|
0
|
|
|
|
|
0
|
warn "There's no Log::Handler->filename in your Catalyst ". |
|
78
|
|
|
|
|
|
|
"app configuration.\n"; |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# Log::Handler->new will fail if there's no filename in the conf. But let's |
|
82
|
|
|
|
|
|
|
# try it anyway to convince the user. |
|
83
|
|
|
|
|
|
|
|
|
84
|
1
|
|
|
|
|
15
|
$self->handler(Log::Handler->new( file => { |
|
85
|
|
|
|
|
|
|
minlevel => 0, |
|
86
|
|
|
|
|
|
|
maxlevel => 7, |
|
87
|
|
|
|
|
|
|
%$config, |
|
88
|
|
|
|
|
|
|
} )); |
|
89
|
1
|
|
|
|
|
15053
|
return $self; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
0
|
|
|
0
|
|
|
*levels = *enable = *disable = sub { return 0; }; |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
1; |
|
95
|
|
|
|
|
|
|
__END__ |