line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
128710
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
2
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
57
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package MooseX::Role::Logger; |
5
|
|
|
|
|
|
|
# ABSTRACT: Provide logging via Log::Any |
6
|
|
|
|
|
|
|
our $VERSION = '0.003'; # VERSION |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
5
|
use Moo::Role; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
9
|
1
|
|
|
1
|
|
1756
|
use Types::Standard qw/Str/; |
|
1
|
|
|
|
|
99343
|
|
|
1
|
|
|
|
|
16
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
1003
|
use Log::Any (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
310
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
#pod =method _logger |
14
|
|
|
|
|
|
|
#pod |
15
|
|
|
|
|
|
|
#pod Returns a logging object. See L for a list of logging methods it accepts. |
16
|
|
|
|
|
|
|
#pod |
17
|
|
|
|
|
|
|
#pod =cut |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has _logger => ( |
20
|
|
|
|
|
|
|
is => 'lazy', |
21
|
|
|
|
|
|
|
isa => sub { ref( $_[0] ) =~ /^Log::Any/ }, # XXX too many options |
22
|
|
|
|
|
|
|
init_arg => undef, |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub _build__logger { |
26
|
1
|
|
|
1
|
|
2915
|
my ($self) = @_; |
27
|
1
|
|
|
|
|
6
|
return Log::Any->get_logger( category => $self->_logger_category ); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has _logger_category => ( |
31
|
|
|
|
|
|
|
is => 'lazy', |
32
|
|
|
|
|
|
|
isa => Str, |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
#pod =method _build__logger_category |
36
|
|
|
|
|
|
|
#pod |
37
|
|
|
|
|
|
|
#pod Override to set the category used for logging. Defaults to the class name of |
38
|
|
|
|
|
|
|
#pod the object (which could be a subclass). You can override to lock it to a |
39
|
|
|
|
|
|
|
#pod particular name: |
40
|
|
|
|
|
|
|
#pod |
41
|
|
|
|
|
|
|
#pod sub _build__logger_category { __PACKAGE__ } |
42
|
|
|
|
|
|
|
#pod |
43
|
|
|
|
|
|
|
#pod =cut |
44
|
|
|
|
|
|
|
|
45
|
1
|
|
|
1
|
|
717
|
sub _build__logger_category { return ref $_[0] } |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# vim: ts=4 sts=4 sw=4 et: |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
__END__ |