line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Log::Log4perl::Appender::Chunk::Store::Memory; |
2
|
|
|
|
|
|
|
$Log::Log4perl::Appender::Chunk::Store::Memory::VERSION = '0.010'; |
3
|
2
|
|
|
2
|
|
1151737
|
use Moose; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
16
|
|
4
|
|
|
|
|
|
|
extends qw/Log::Log4perl::Appender::Chunk::Store/; |
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
13970
|
use Log::Log4perl; |
|
2
|
|
|
|
|
52755
|
|
|
2
|
|
|
|
|
12
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
my $LOGGER = Log::Log4perl->get_logger(); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has 'chunks' => ( is => 'rw' , isa => 'HashRef[Str]' , default => sub{ {}; }); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub clear{ |
14
|
0
|
|
|
0
|
1
|
0
|
my ($self) = @_; |
15
|
0
|
|
|
|
|
0
|
$self->chunks({}); |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub store{ |
19
|
5
|
|
|
5
|
1
|
11
|
my ($self, $chunk_id, $big_message) = @_; |
20
|
5
|
|
|
|
|
18
|
$LOGGER->trace("Storing chunk ".$chunk_id); |
21
|
5
|
|
|
|
|
269
|
$self->chunks()->{$chunk_id} = $big_message; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable(); |
27
|
|
|
|
|
|
|
__END__ |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 NAME |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Log::Log4perl::Appender::Chunk::Store::Memory - Stores chunks in memory |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 SYNOPSIS |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Fist make sure you read L<Log::Log4perl::Appender::Chunk> documentation. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
l4p.conf: |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
log4perl.rootLogger=TRACE, Chunk |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
layout_class=Log::Log4perl::Layout::PatternLayout |
42
|
|
|
|
|
|
|
layout_pattern=%m%n |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
log4perl.appender.Chunk=Log::Log4perl::Appender::Chunk |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# Built-in store class Memory |
47
|
|
|
|
|
|
|
log4perl.appender.Chunk.store_class=Memory |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Then from your code: |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my $store = Log::Log4perl->appender_by_name('Chunk')->store(); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
You can then inspect |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
$store->chunks(); # A hash of all the chunks by chunk ID |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Save memory from time to time: |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
$store->clear(); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head2 store |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
See L<Log::Log4perl::Appender::Chunk::Store> |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head2 clear |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Clears the chunks storage. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=cut |