line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Log::Any::Adapter::Journal; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Adapter for Log::Any that outputs with a priority prefix that systemd's journal can parse |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
455
|
use 5.010; |
|
1
|
|
|
|
|
2
|
|
6
|
1
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
16
|
|
7
|
1
|
|
|
1
|
|
10
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
3
|
use Log::Any::Adapter::Util qw(logging_methods numeric_level); |
|
1
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
57
|
|
10
|
1
|
|
|
1
|
|
385
|
use parent 'Log::Any::Adapter::Screen'; |
|
1
|
|
|
|
|
220
|
|
|
1
|
|
|
|
|
3
|
|
11
|
1
|
|
|
1
|
|
1928
|
use Class::Method::Modifiers; |
|
1
|
|
|
|
|
1001
|
|
|
1
|
|
|
|
|
161
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.13'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# sub init { |
16
|
|
|
|
|
|
|
# my ($self) = @_; |
17
|
|
|
|
|
|
|
# } |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# Journal doesn't recognize trace, use debug instead |
20
|
1
|
|
|
1
|
0
|
924
|
sub trace { shift->debug(@_) } |
21
|
1
|
|
|
1
|
0
|
266
|
sub is_trace { shift->is_debug(@_) } |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# For each of the logging methods exposed by Log::Any, add the level |
24
|
|
|
|
|
|
|
# prefix in angled brackets. |
25
|
|
|
|
|
|
|
for my $method ( grep { !/trace/ } logging_methods ) { |
26
|
|
|
|
|
|
|
my $level = numeric_level( $method ); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
before $method => sub { |
29
|
|
|
|
|
|
|
$_[1] = "<$level>$_[1]" unless $_[0]->{use_color}; |
30
|
|
|
|
|
|
|
}; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# Log::Any levels Journal levels |
34
|
|
|
|
|
|
|
# 0 emergency 0 emerg |
35
|
|
|
|
|
|
|
# 1 alert 1 alert |
36
|
|
|
|
|
|
|
# 2 critical 2 crit |
37
|
|
|
|
|
|
|
# 3 error 3 err |
38
|
|
|
|
|
|
|
# 4 warning 4 warning |
39
|
|
|
|
|
|
|
# 5 notice 5 notice |
40
|
|
|
|
|
|
|
# 6 info 6 info |
41
|
|
|
|
|
|
|
# 7 debug 7 debug |
42
|
|
|
|
|
|
|
# 8 trace |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
__END__ |