line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catalyst::Plugin::Log::Log4perl; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
23446
|
use namespace::autoclean; |
|
1
|
|
|
|
|
32402
|
|
|
1
|
|
|
|
|
5
|
|
4
|
1
|
|
|
1
|
|
1989
|
use Log::Log4perl; |
|
1
|
|
|
|
|
86799
|
|
|
1
|
|
|
|
|
10
|
|
5
|
1
|
|
|
1
|
|
656
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub setup { |
11
|
|
|
|
|
|
|
my $c = shift; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $config = $c->config->{'Plugin::Log::Log4perl'}; |
14
|
|
|
|
|
|
|
if( exists $config->{conf} ) { |
15
|
|
|
|
|
|
|
if( defined $config->{watch_delay} ) { |
16
|
|
|
|
|
|
|
Log::Log4perl->init_and_watch( $config->{conf}, $config->{watch_delay} ); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
else { |
19
|
|
|
|
|
|
|
Log::Log4perl->init( $config->{conf} ); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
else { |
23
|
|
|
|
|
|
|
$c->log->warn( 'No Log::Log4perl configuration found' ); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
$c->next::method( @_ ) |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
1 |
31
|
|
|
|
|
|
|
__END__ |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=pod |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 NAME |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Catalyst::Plugin::Log::Log4perl - Catalyst plugin to initialize Log::Log4perl from the application's configuration |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 SYNOPSIS |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# in MyApp.pm |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
use Catalyst qw( ConfigLoader Log::Log4perl ); |
44
|
|
|
|
|
|
|
use Log::Log4perl::Catalyst; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
... |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__PACKAGE__->log( Log::Log4perl::Catalyst->new ); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__PACKAGE__->setup; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# in myapp.yaml |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
name: MyApp |
56
|
|
|
|
|
|
|
Plugin::Log::Log4perl: |
57
|
|
|
|
|
|
|
conf: '__HOME__/log4perl.conf' |
58
|
|
|
|
|
|
|
watch_delay: 60 # optional |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 DESCRIPTION |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
This module allows you to initialize L<Log::Log4perl|Log::Log4perl> |
63
|
|
|
|
|
|
|
within the application's configuration. This is especially useful |
64
|
|
|
|
|
|
|
when using L<Catalyst::Plugin::ConfigLoader|Catalyst::Plugin::ConfigLoader> |
65
|
|
|
|
|
|
|
to load configuration files. It is meant to be used in conjunction |
66
|
|
|
|
|
|
|
with L<Log::Log4perl::Catalyst|Log::Log4perl::Catalyst>, but can |
67
|
|
|
|
|
|
|
also be used stand-alone. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 CONFIGURATION |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 conf |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
This will be passed directly to C<Log::Log4perl-E<gt>init()>, so it can |
74
|
|
|
|
|
|
|
be anything that that method can support. This includes the name |
75
|
|
|
|
|
|
|
of a configuration file or a C<HASH> reference. See the |
76
|
|
|
|
|
|
|
L<Log::Log4perl|Log::Log4perl> documentation for more information. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 watch_delay |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
If this is present, C<Log::Log4perl-E<gt>init_and_watch()> is used |
81
|
|
|
|
|
|
|
for L<Log::Log4perl|Log::Log4perl> initialization with the given delay. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 BUGS |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
If L<Log::Log4perl::Catalyst|Log::Log4perl::Catalyst> is used, |
86
|
|
|
|
|
|
|
this module will re-initialize L<Log::Log4perl|Log::Log4perl> |
87
|
|
|
|
|
|
|
which is not recommended. This is unavoidable, though, since your |
88
|
|
|
|
|
|
|
application's logger is configured prior to running C<MyApp-E<gt>setup()>. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 AUTHOR |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
jason hord <pravus@cpan.org> |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 SEE ALSO |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=over 2 |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=item L<Log::Log4perl|Log::Log4perl> |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=item L<Log::Log4perl::Catalyst|Log::Log4perl::Catalyst> |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=back |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 COPYRIGHT |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Copyright (c) 2010-2014, jason hord |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy |
109
|
|
|
|
|
|
|
of this software and associated documentation files (the "Software"), to deal |
110
|
|
|
|
|
|
|
in the Software without restriction, including without limitation the rights |
111
|
|
|
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
112
|
|
|
|
|
|
|
copies of the Software, and to permit persons to whom the Software is |
113
|
|
|
|
|
|
|
furnished to do so, subject to the following conditions: |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in |
116
|
|
|
|
|
|
|
all copies or substantial portions of the Software. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
119
|
|
|
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
120
|
|
|
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
121
|
|
|
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
122
|
|
|
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
123
|
|
|
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
124
|
|
|
|
|
|
|
THE SOFTWARE. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=cut |