line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojar::Log; |
2
|
2
|
|
|
2
|
|
32255
|
use Mojo::Base 'Mojo::Log'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
10
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = 1.002; |
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
36142
|
use Mojo::Util 'encode'; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
66
|
|
7
|
2
|
|
|
2
|
|
802
|
use POSIX 'strftime'; |
|
2
|
|
|
|
|
8190
|
|
|
2
|
|
|
|
|
7
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub import { |
10
|
3
|
|
|
3
|
|
698
|
my $pkg = shift; |
11
|
|
|
|
|
|
|
# Mixin |
12
|
3
|
100
|
|
|
|
15
|
if (@_) { |
13
|
2
|
|
|
|
|
4
|
my @args = @_; |
14
|
2
|
|
|
2
|
|
4
|
my $default = sub { Mojar::Log->new(@args) }; |
|
2
|
|
|
|
|
9
|
|
15
|
2
|
50
|
33
|
2
|
|
123
|
eval sprintf |
|
2
|
|
33
|
2
|
|
1458
|
|
|
2
|
|
|
|
|
2961
|
|
|
1
|
|
|
|
|
47
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
41
|
|
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__ |