| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Log::ger::Output::ArrayRotate; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $DATE = '2017-07-16'; # DATE |
|
4
|
|
|
|
|
|
|
our $VERSION = '0.001'; # VERSION |
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
4832
|
use strict; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
43
|
|
|
7
|
1
|
|
|
1
|
|
10
|
use warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
245
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub get_hooks { |
|
10
|
1
|
|
|
1
|
0
|
24
|
my %conf = @_; |
|
11
|
|
|
|
|
|
|
|
|
12
|
1
|
50
|
|
|
|
7
|
my $ary = $conf{array} or die "Please specify array"; |
|
13
|
1
|
50
|
|
|
|
6
|
ref $ary eq 'ARRAY' or die "Please specify arrayref in array"; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
return { |
|
16
|
|
|
|
|
|
|
create_log_routine => [ |
|
17
|
|
|
|
|
|
|
__PACKAGE__, 50, |
|
18
|
|
|
|
|
|
|
sub { |
|
19
|
6
|
|
|
6
|
|
3578
|
my %args = @_; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $logger = sub { |
|
22
|
4
|
|
|
|
|
1979
|
my ($ctx, $msg) = @_; |
|
23
|
4
|
|
|
|
|
12
|
push @$ary, $msg; |
|
24
|
4
|
100
|
66
|
|
|
39
|
if (defined $conf{max_elems} && @$ary > $conf{max_elems}) { |
|
25
|
1
|
|
|
|
|
5
|
shift @$ary; |
|
26
|
|
|
|
|
|
|
} |
|
27
|
6
|
|
|
|
|
39
|
}; |
|
28
|
6
|
|
|
|
|
34
|
[$logger]; |
|
29
|
1
|
|
|
|
|
15
|
}], |
|
30
|
|
|
|
|
|
|
}; |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
1; |
|
34
|
|
|
|
|
|
|
# ABSTRACT: Log to array, rotating old elements |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
__END__ |