line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Fluent::Logger; |
2
|
5
|
|
|
5
|
|
99973
|
use 5.008001; |
|
5
|
|
|
|
|
14
|
|
3
|
5
|
|
|
5
|
|
19
|
use strict; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
97
|
|
4
|
5
|
|
|
5
|
|
21
|
use warnings; |
|
5
|
|
|
|
|
5
|
|
|
5
|
|
|
|
|
145
|
|
5
|
5
|
|
|
5
|
|
18
|
no warnings qw/redefine/; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
441
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = "0.02"; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
require Exporter; |
10
|
|
|
|
|
|
|
our @ISA = qw/Exporter/; |
11
|
|
|
|
|
|
|
our @EXPORT = qw/get_fluent_logs clear_fluent_logs/; |
12
|
|
|
|
|
|
|
our @EXPORT_OK = qw/is_active activate deactivate/; |
13
|
|
|
|
|
|
|
|
14
|
5
|
|
|
5
|
|
1826
|
use Fluent::Logger; |
|
5
|
|
|
|
|
147328
|
|
|
5
|
|
|
|
|
1020
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $original__post = Fluent::Logger->can('_post'); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $is_active; |
19
|
|
|
|
|
|
|
my @fluent_logs; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub is_active () { |
22
|
7
|
|
|
7
|
0
|
4381
|
return $is_active; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub import { |
26
|
4
|
|
|
4
|
|
268
|
Test::Fluent::Logger->export_to_level(1, @_); |
27
|
|
|
|
|
|
|
|
28
|
4
|
|
|
|
|
9
|
activate(); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
*Fluent::Logger::_post = sub { |
31
|
11
|
100
|
|
11
|
|
7912
|
if ($is_active) { |
32
|
9
|
|
|
|
|
13
|
my ($self, $tag, $msg, $time) = @_; |
33
|
9
|
|
100
|
|
|
138
|
push @fluent_logs, { |
34
|
|
|
|
|
|
|
message => $msg, |
35
|
|
|
|
|
|
|
time => $time, |
36
|
|
|
|
|
|
|
tag_prefix => $self->tag_prefix || "", |
37
|
|
|
|
|
|
|
}; |
38
|
|
|
|
|
|
|
} else { |
39
|
2
|
|
|
|
|
10
|
$original__post->(@_); |
40
|
|
|
|
|
|
|
} |
41
|
4
|
|
|
|
|
4366
|
}; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub unimport { |
45
|
1
|
|
|
1
|
|
7
|
deactivate(); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub activate () { |
49
|
6
|
|
|
6
|
1
|
694
|
$is_active = 1; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub deactivate () { |
53
|
3
|
|
|
3
|
1
|
1238
|
$is_active = 0; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub clear_fluent_logs () { |
57
|
5
|
|
|
5
|
1
|
9139
|
@fluent_logs = (); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub get_fluent_logs () { |
61
|
7
|
|
|
7
|
1
|
45
|
return @fluent_logs; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
__END__ |