line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catalyst::Plugin::Log::Handler; |
2
|
2
|
|
|
2
|
|
35358
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
50
|
|
3
|
2
|
|
|
2
|
|
6
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
98
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Catalyst::Plugin::Log::Handler - Catalyst Plugin for Log::Handler |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 VERSION |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Version 0.07_01 (developer release) |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=cut |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = '0.07_01'; |
16
|
|
|
|
|
|
|
|
17
|
2
|
|
|
2
|
|
770
|
use MRO::Compat; |
|
2
|
|
|
|
|
4622
|
|
|
2
|
|
|
|
|
148
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub setup { |
20
|
1
|
|
|
1
|
0
|
172
|
my $c = shift; |
21
|
|
|
|
|
|
|
|
22
|
1
|
|
50
|
|
|
3
|
my $config = $c->config->{'Log::Handler'} || {}; |
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
|
|
12
|
$c->log((__PACKAGE__ . '::Backend')->new($config)); |
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
|
|
8
|
return $c->maybe::next::method(@_); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
package Catalyst::Plugin::Log::Handler::Backend; |
31
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
29
|
|
32
|
2
|
|
|
2
|
|
5
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
49
|
|
33
|
2
|
|
|
2
|
|
6
|
use base qw(Class::Accessor::Fast); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
847
|
|
34
|
2
|
|
|
2
|
|
5644
|
use Log::Handler 0.63; |
|
2
|
|
|
|
|
77187
|
|
|
2
|
|
|
|
|
14
|
|
35
|
2
|
|
|
2
|
|
69
|
use MRO::Compat; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
15
|
|
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
|
|
862
|
my $self = shift; |
53
|
|
|
|
|
|
|
|
54
|
5
|
|
|
|
|
10
|
$self->handler->$handlerlevel(@_); |
55
|
|
|
|
|
|
|
}; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
my $handlerfunc = "is_$handlerlevel"; |
58
|
|
|
|
|
|
|
my $testsub = sub { |
59
|
5
|
|
|
5
|
|
2613
|
my $self = shift; |
60
|
|
|
|
|
|
|
|
61
|
5
|
|
|
|
|
14
|
$self->handler->$handlerfunc(); |
62
|
|
|
|
|
|
|
}; |
63
|
|
|
|
|
|
|
|
64
|
2
|
|
|
2
|
|
202
|
no strict 'refs'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
286
|
|
65
|
|
|
|
|
|
|
*{$catlevel} = $logsub; |
66
|
|
|
|
|
|
|
*{"is_$catlevel"} = $testsub; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub new { |
71
|
1
|
|
|
1
|
|
1
|
my $class = shift; |
72
|
1
|
|
|
|
|
9
|
my $self = $class->next::method(); |
73
|
|
|
|
|
|
|
|
74
|
1
|
|
|
|
|
28
|
my ($config) = @_; |
75
|
|
|
|
|
|
|
|
76
|
1
|
50
|
|
|
|
4
|
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
|
|
|
|
|
12
|
$self->handler(Log::Handler->new( file => { |
85
|
|
|
|
|
|
|
minlevel => 0, |
86
|
|
|
|
|
|
|
maxlevel => 7, |
87
|
|
|
|
|
|
|
%$config, |
88
|
|
|
|
|
|
|
} )); |
89
|
1
|
|
|
|
|
4372
|
return $self; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
0
|
|
|
0
|
|
|
*levels = *enable = *disable = sub { return 0; }; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
1; |
95
|
|
|
|
|
|
|
__END__ |