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