line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojar::Log; |
2
|
2
|
|
|
2
|
|
34501
|
use Mojo::Base 'Mojo::Log'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
11
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = 1.002; |
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
83462
|
use Mojo::Util 'encode'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
70
|
|
7
|
2
|
|
|
2
|
|
939
|
use POSIX 'strftime'; |
|
2
|
|
|
|
|
9964
|
|
|
2
|
|
|
|
|
10
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub import { |
10
|
3
|
|
|
3
|
|
809
|
my $pkg = shift; |
11
|
|
|
|
|
|
|
# Mixin |
12
|
3
|
100
|
|
|
|
18
|
if (@_) { |
13
|
2
|
|
|
|
|
5
|
my @args = @_; |
14
|
2
|
|
|
2
|
|
4
|
my $default = sub { Mojar::Log->new(@args) }; |
|
2
|
|
|
|
|
19
|
|
15
|
2
|
50
|
33
|
2
|
|
127
|
eval sprintf |
|
2
|
|
33
|
2
|
|
3448
|
|
|
2
|
|
|
|
|
4030
|
|
|
1
|
|
|
|
|
48
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
44
|
|
16
|
|
|
|
|
|
|
'package %s; no strict q{refs}; sub log { $_[0]{log} //= $default->() }; 1', |
17
|
|
|
|
|
|
|
scalar caller |
18
|
|
|
|
|
|
|
or die 'Failed to create Mojar::Log mixin'; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# Attributes |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has pattern => '%Y%m%d %H:%M:%S'; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has format => sub { |
27
|
|
|
|
|
|
|
my $self = shift; weaken $self; sub { |
28
|
|
|
|
|
|
|
my ($time, $level, @lines) = @_; |
29
|
|
|
|
|
|
|
encode 'UTF-8', sprintf '%s[%s] %s', strftime($self->pattern, |
30
|
|
|
|
|
|
|
localtime($time)), $level, join "\n", @lines, '' |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
}; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
1; |
35
|
|
|
|
|
|
|
__END__ |