line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooseX::Log::Log4perl::Easy; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
5256
|
use Any::Moose 'Role'; |
|
2
|
|
|
|
|
1468
|
|
|
2
|
|
|
|
|
13
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
with 'MooseX::Log::Log4perl'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.46'; |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
1
|
141
|
sub log_fatal { local $Log::Log4perl::caller_depth += 1; return shift->logger->fatal(@_); } |
|
1
|
|
|
|
|
31
|
|
10
|
1
|
|
|
1
|
1
|
186
|
sub log_error { local $Log::Log4perl::caller_depth += 1; return shift->logger->error(@_); } |
|
1
|
|
|
|
|
38
|
|
11
|
1
|
|
|
1
|
1
|
156
|
sub log_warn { local $Log::Log4perl::caller_depth += 1; return shift->logger->warn(@_); } |
|
1
|
|
|
|
|
32
|
|
12
|
1
|
|
|
1
|
1
|
142
|
sub log_info { local $Log::Log4perl::caller_depth += 1; return shift->logger->info(@_); } |
|
1
|
|
|
|
|
30
|
|
13
|
1
|
|
|
1
|
1
|
237
|
sub log_debug { local $Log::Log4perl::caller_depth += 1; return shift->logger->debug(@_); } |
|
1
|
|
|
|
|
32
|
|
14
|
1
|
|
|
1
|
1
|
6835
|
sub log_trace { local $Log::Log4perl::caller_depth += 1; return shift->logger->trace(@_); } |
|
1
|
|
|
|
|
37
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
1; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
__END__ |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 NAME |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
MooseX::Log::Log4perl::Easy - A role for easy usage of logging in your Moose based modules based on L<MooseX::Log::Log4perl> |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 SYNOPSIS |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
package MyApp; |
27
|
|
|
|
|
|
|
use Moose; |
28
|
|
|
|
|
|
|
use Log::Log4perl qw(:easy); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
with 'MooseX::Log::Log4perl::Easy'; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
BEGIN { |
33
|
|
|
|
|
|
|
Log::Log4perl->easy_init(); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub foo { |
37
|
|
|
|
|
|
|
my ($self) = @_; |
38
|
|
|
|
|
|
|
$self->log_debug("started bar"); ### logs with default class catergory "MyApp" |
39
|
|
|
|
|
|
|
$self->log_info('bar'); ### logs an info message |
40
|
|
|
|
|
|
|
$self->log('AlsoPossible')->fatal("croak"); ### log |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 DESCRIPTION |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
The Easy logging role based on the L<MooseX::Log::Log4perl> logging role for Moose directly adds the |
46
|
|
|
|
|
|
|
logmethods for all available levels to your class instance. Hence it is possible to use |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
$self->log_info("blabla"); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
without having to access a separate log attribute as in MooseX::Log::Log4perl; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
In case your app grows and you need more of the super-cow powers of Log4perl or simply don't want the additional |
53
|
|
|
|
|
|
|
methods to clutter up your class you can simply replace all code C<< $self->log_LEVEL >> with |
54
|
|
|
|
|
|
|
C<< $self->log->LEVEL >>. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
You can use the following regex substitution to accomplish that: |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
s/log(_(trace|debug|info|warn|error|fatal))/log->$2/g |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 ACCESSORS |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head2 logger |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
See L<MooseX::Log::Log4perl> |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 log |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
See L<MooseX::Log::Log4perl> |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head2 log_fatal ($msg) |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Logs a fatal message $msg using the logger attribute. Same as calling |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
$self->logger->fatal($msg) |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 log_error ($msg) |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Logs an error message using the logger attribute. Same as calling |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
$self->logger->error($msg) |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 log_warn ($msg) |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Logs a warn message using the logger attribute. Same as calling |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
$self->logger->warn($msg) |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head2 log_info ($msg) |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Logs an info message using the logger attribute. Same as calling |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
$self->logger->info($msg) |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 log_debug ($msg) |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Logs a debug message using the logger attribute. Same as calling |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
$self->logger->debug($msg) |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head2 log_trace ($msg) |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Logs a trace message using the logger attribute. Same as calling |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
$self->logger->trace($msg) |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 SEE ALSO |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
L<MooseX::Log::Log4perl>, L<Log::Log4perl>, L<Moose> |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
113
|
|
|
|
|
|
|
C<bug-moosex-log4perl@rt.cpan.org>, or through the web interface at |
114
|
|
|
|
|
|
|
L<http://rt.cpan.org>. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Or come bother us in C<#moose> on C<irc.perl.org>. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 AUTHOR |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Roland Lammel C<< <lammel@cpan.org> >> |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Inspired by suggestions by Michael Schilli C<< <m@perlmeister.com> >> |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Contributions from Tim Bunce C<< <TIMB@cpan.org> >> |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Copyright (c) 2008-2012, Roland Lammel C<< <lammel@cpan.org> >>, http://www.quikit.at |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or |
131
|
|
|
|
|
|
|
modify it under the same terms as Perl itself. See L<perlartistic>. |
132
|
|
|
|
|
|
|
|