line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Log::ger::Output::String; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
4
|
|
|
|
|
|
|
our $DATE = '2021-01-31'; # DATE |
5
|
|
|
|
|
|
|
our $DIST = 'Log-ger'; # DIST |
6
|
|
|
|
|
|
|
our $VERSION = '0.038'; # VERSION |
7
|
|
|
|
|
|
|
|
8
|
4
|
|
|
4
|
|
28
|
use strict; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
122
|
|
9
|
4
|
|
|
4
|
|
20
|
use warnings; |
|
4
|
|
|
|
|
23
|
|
|
4
|
|
|
|
|
1151
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub meta { +{ |
12
|
10
|
|
|
10
|
0
|
38
|
v => 2, |
13
|
|
|
|
|
|
|
} } |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub get_hooks { |
16
|
10
|
|
|
10
|
0
|
27
|
my %plugin_conf = @_; |
17
|
|
|
|
|
|
|
|
18
|
10
|
50
|
|
|
|
27
|
$plugin_conf{string} or die "Please specify string"; |
19
|
|
|
|
|
|
|
|
20
|
10
|
|
|
|
|
18
|
my $formatter = $plugin_conf{formatter}; |
21
|
10
|
|
|
|
|
14
|
my $append_newline = $plugin_conf{append_newline}; |
22
|
10
|
100
|
|
|
|
27
|
$append_newline = 1 unless defined $append_newline; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
return { |
25
|
|
|
|
|
|
|
create_outputter => [ |
26
|
|
|
|
|
|
|
__PACKAGE__, # key |
27
|
|
|
|
|
|
|
50, # priority |
28
|
|
|
|
|
|
|
sub { # hook |
29
|
175
|
|
|
175
|
|
513
|
my %hook_args = @_; # see Log::ger::Manual::Internals/"Arguments passed to hook" |
30
|
175
|
|
|
|
|
267
|
my $level = $hook_args{level}; |
31
|
|
|
|
|
|
|
my $outputter = sub { |
32
|
41
|
|
|
|
|
84
|
my ($per_target_conf, $msg, $per_msg_conf) = @_; |
33
|
41
|
50
|
|
|
|
79
|
if ($formatter) { |
34
|
0
|
|
|
|
|
0
|
$msg = $formatter->($msg); |
35
|
|
|
|
|
|
|
} |
36
|
41
|
|
|
|
|
49
|
${ $plugin_conf{string} } .= $msg; |
|
41
|
|
|
|
|
90
|
|
37
|
41
|
100
|
66
|
|
|
192
|
${ $plugin_conf{string} } .= "\n" |
|
38
|
|
|
|
|
96
|
|
38
|
|
|
|
|
|
|
unless !$append_newline || $msg =~ /\R\z/; |
39
|
175
|
|
|
|
|
689
|
}; |
40
|
175
|
|
|
|
|
510
|
[$outputter]; |
41
|
10
|
|
|
|
|
79
|
}], |
42
|
|
|
|
|
|
|
}; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |
46
|
|
|
|
|
|
|
# ABSTRACT: Set output to a string |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__END__ |