Collector/Output/Console/Logs.pm

filter: Statementstmt 83.3% 10 / 12 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 87.5% 14 / 16 CC 1 SCAR 0.7
CC
1
Cov
83%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« Collector/Output/Console/Alerts.pm ↑ Summary Collector.pm »
1 package XAS::Collector::Output::Console::Logs;
2  
3 our $VERSION = '0.01';
4  
5 1 ▶use POE;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 use XAS::Class
10 0 ▶ debug => 0,
Subroutine BEGIN: called CC=1 SCAR=2.6
11 version => $VERSION,
12 base => 'XAS::Collector::Output::Console::Base',
13 1 ;
14  
15 # --------------------------------------------------------------------
16 # Public Events
17 # --------------------------------------------------------------------
18  
19 sub store_data {
20 my ($self, $data, $ack, $input) = @_[OBJECT,ARG0...ARG2];
21  
22 my $buffer;
23 my $alias = $self->alias;
24 my $schema = $self->schema;
25  
26 $self->log->debug("$alias: entering store_data()");
27  
28 $buffer = sprintf('%s: hostname = %s; timestamp = %s; level = %s; facility = %s; message = %s',
29 $alias, $data->{'hostname'},
30 $data->{'datetime'}, $data->{'level'},
31 $data->{'facility'}, $data->{'message'}
32 );
33  
34 $self->log->debug($buffer);
35  
36 $self->log->info(Dumper($data));
37 $self->log->info_msg('collector_processed', $alias, 1, $data->{'hostname'}, $data->{'datetime'});
38
39 $poe_kernel->post($input, 'write_data', $ack);
40  
41 $self->log->debug("$alias: leaving store_data()");
42  
43 }
44  
45 # --------------------------------------------------------------------
46 # Public Methods
47 # --------------------------------------------------------------------
48  
49 # --------------------------------------------------------------------
50 # Private Methods
51 # --------------------------------------------------------------------
52  
53 1;
54  
55 __END__
56  
57 =head1 NAME
58  
59 XAS::Collector::Output::Console::Logs - Perl extension for the XAS Environment
60  
61 =head1 SYNOPSIS
62  
63 use XAS::Collector::Output::Console::Logs;
64  
65 my $output = XAS::Collector::Output::Console::Logs->new(
66 -alias => 'console-logs',
67 );
68  
69 =head1 DESCRIPTION
70  
71 This module handles the xas-logs packet type.
72  
73 =head1 METHODS
74  
75 =head2 new
76  
77 This module inherits from L<XAS::Collector::Output::Console::Base|XAS::Collector::Output::Console::Base>
78 and takes the same parameters.
79  
80 =head1 PUBLIC EVENTS
81  
82 =head2 store_data(OBJECT, ARG0, ARG1, ARG2)
83  
84 This event will dump xas-logs packets to the console using
85 L<Data::Dumper|https://metacpan.org/pod/Data::Dumper>.
86  
87 =over 4
88  
89 =item B<OBJECT>
90  
91 A handle to the current object.
92  
93 =item B<ARG0>
94  
95 The data to be stored within the database.
96  
97 =item B<ARG1>
98  
99 The acknowledgement to send back to the message queue server.
100  
101 =item B<ARG2>
102  
103 The input to return the ack too.
104  
105 =back
106  
107 =head1 SEE ALSO
108  
109 =over 4
110  
111 =item L<XAS::Collector::Output::Console::Base|XAS::Collector::Output::Console::Base>
112  
113 =item L<XAS::Collector::Output::Console::Alerts|XAS::Collector::Output::Console::Alerts>
114  
115 =item L<XAS::Collector|XAS::Collector>
116  
117 =item L<XAS|XAS>
118  
119 =back
120  
121 =head1 AUTHOR
122  
123 Kevin Esteb, E<lt>kevin@kesteb.usE<gt>
124  
125 =head1 COPYRIGHT AND LICENSE
126  
127 Copyright (c) 2012-2015 Kevin L. Esteb
128  
129 This is free software; you can redistribute it and/or modify it under
130 the terms of the Artistic License 2.0. For details, see the full text
131 of the license at http://www.perlfoundation.org/artistic_license_2_0.
132  
133 =cut
« Collector/Output/Console/Alerts.pm ↑ Summary Collector.pm »