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