line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojar::Log; |
2
|
2
|
|
|
2
|
|
35548
|
use Mojo::Base 'Mojo::Log'; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
9
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = 1.002; |
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
88311
|
use Mojo::Util 'encode'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
121
|
|
7
|
2
|
|
|
2
|
|
873
|
use POSIX 'strftime'; |
|
2
|
|
|
|
|
9429
|
|
|
2
|
|
|
|
|
11
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub import { |
10
|
3
|
|
|
3
|
|
809
|
my $pkg = shift; |
11
|
|
|
|
|
|
|
# Mixin |
12
|
3
|
100
|
|
|
|
18
|
if (@_) { |
13
|
2
|
|
|
|
|
6
|
my @args = @_; |
14
|
2
|
|
|
2
|
|
7
|
my $default = sub { Mojar::Log->new(@args) }; |
|
2
|
|
|
|
|
11
|
|
15
|
2
|
50
|
33
|
2
|
|
126
|
eval sprintf |
|
2
|
|
33
|
2
|
|
2229
|
|
|
2
|
|
|
|
|
2673
|
|
|
1
|
|
|
|
|
44
|
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
47
|
|
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__ |