Collector/Format/Alerts.pm

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