line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Log::ger::Output::String; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
26
|
use strict; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
146
|
|
4
|
4
|
|
|
4
|
|
20
|
use warnings; |
|
4
|
|
|
|
|
20
|
|
|
4
|
|
|
|
|
1073
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
7
|
|
|
|
|
|
|
our $DATE = '2022-06-10'; # DATE |
8
|
|
|
|
|
|
|
our $DIST = 'Log-ger'; # DIST |
9
|
|
|
|
|
|
|
our $VERSION = '0.040'; # VERSION |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub meta { +{ |
12
|
10
|
|
|
10
|
0
|
56
|
v => 2, |
13
|
|
|
|
|
|
|
} } |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub get_hooks { |
16
|
10
|
|
|
10
|
0
|
30
|
my %plugin_conf = @_; |
17
|
|
|
|
|
|
|
|
18
|
10
|
50
|
|
|
|
30
|
$plugin_conf{string} or die "Please specify string"; |
19
|
|
|
|
|
|
|
|
20
|
10
|
|
|
|
|
15
|
my $formatter = $plugin_conf{formatter}; |
21
|
10
|
|
|
|
|
20
|
my $append_newline = $plugin_conf{append_newline}; |
22
|
10
|
100
|
|
|
|
23
|
$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
|
|
410
|
my %hook_args = @_; # see Log::ger::Manual::Internals/"Arguments passed to hook" |
30
|
175
|
|
|
|
|
229
|
my $level = $hook_args{level}; |
31
|
|
|
|
|
|
|
my $outputter = sub { |
32
|
41
|
|
|
|
|
71
|
my ($per_target_conf, $msg, $per_msg_conf) = @_; |
33
|
41
|
50
|
|
|
|
66
|
if ($formatter) { |
34
|
0
|
|
|
|
|
0
|
$msg = $formatter->($msg); |
35
|
|
|
|
|
|
|
} |
36
|
41
|
|
|
|
|
47
|
${ $plugin_conf{string} } .= $msg; |
|
41
|
|
|
|
|
76
|
|
37
|
41
|
100
|
66
|
|
|
148
|
${ $plugin_conf{string} } .= "\n" |
|
38
|
|
|
|
|
75
|
|
38
|
|
|
|
|
|
|
unless !$append_newline || $msg =~ /\R\z/; |
39
|
175
|
|
|
|
|
558
|
}; |
40
|
175
|
|
|
|
|
424
|
[$outputter]; |
41
|
10
|
|
|
|
|
72
|
}], |
42
|
|
|
|
|
|
|
}; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |
46
|
|
|
|
|
|
|
# ABSTRACT: Set output to a string |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__END__ |