File Coverage

blib/lib/Log/Log4perl/Appender/Chunk/Store.pm
Criterion Covered Total %
statement 6 8 75.0
branch n/a
condition n/a
subroutine 2 3 66.6
pod 1 1 100.0
total 9 12 75.0


line stmt bran cond sub pod time code
1             package Log::Log4perl::Appender::Chunk::Store;
2             $Log::Log4perl::Appender::Chunk::Store::VERSION = '0.009';
3 4     4   21447 use Moose;
  4         10  
  4         28  
4              
5 4     4   19513 use Carp;
  4         8  
  4         636  
6              
7             sub store{
8 0     0 1   my ($self, $chunk_id , $big_message) = @_;
9 0           die "sub 'store' is not Implemented in $self";
10             }
11              
12             __PACKAGE__->meta->make_immutable();
13              
14             __END__
15              
16             =head1 NAME
17              
18             Log::Log4perl::Appender::Chunk::Store - Store adapter baseclass
19              
20             =head1 DESCRIPTION
21              
22             This is the baseclass for all Store adapters used by the
23             L<Log::Log4perl::Appender::Chunk> appender.
24              
25             =head1 IMPLEMENTING YOUR OWN
26              
27             =head2 Write your subclass
28              
29             Make a Moose subclass of this and implement the 'store' method.
30              
31             Have a look at the minimalistic code in L<Log::Log4perl::Appender::Chunk::Store::Memory>.
32              
33             Settings:
34              
35             Settings should be plain Scalar Moose attributes. They will be injected from the configuration
36             file key 'store_args'.
37              
38             =head2 Use your Store from the config file.
39              
40             Set the store_class property of your Chunk appender to something like:
41              
42             log4perl.appender.Chunk.store_class=+My::L4p::Appender::Chunk::Store::MyStorage
43              
44             Remember you can set some your storage class parameters like:
45              
46             log4perl.appender.Chunk.store_args.my_setting1=Setting1Value
47             log4perl.appender.Chunk.store_args.my_setting2=Setting2Value
48              
49              
50             =head2 Use your Store from your application code.
51              
52             If your Storage is too complex to build itself only from the configuration file properties, you can perfectly
53             build an instance of it and inject it in your Chunk Appender at run time (do that only once right after L4P init):
54              
55             my $store = .. An instance of your My::L4p::Appender::Chunk::Store::MyStorage
56             if( my $chunk_appender = Log::Log4perl->appender_by_name('Chunk') ){
57             $chunk_appender->store($store);
58             }
59              
60             Don't forget to change 'Chunk' by whatever name you gave to your Chunk appender in the config file.
61              
62             =head1 METHODS
63              
64             =head2 store
65              
66             This method will be called by the L<Log::Log4perl::Appender::Chunk> to store a whole chunk of log lines
67             under the given chunk ID.
68              
69             Implement it in any subclass like:
70              
71             sub store{
72             my ($self, $chunk_id, $chunk) = @_;
73             ...
74             }
75              
76             =cut