| 1 | package Log::Saftpresse::Plugin::SyslogFile; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | # ABSTRACT: plugin to parse syslog logfile format | ||||||||||
| 6 | 1 | our $VERSION = '1.5'; # VERSION | |||||||||
| 7 | |||||||||||
| 8 | 1 | extends 'Log::Saftpresse::Plugin'; | |||||||||
| 9 | |||||||||||
| 10 | 1 | ▶ | use Time::Piece; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | sub process { | ||||||||||
| 13 | 0 | ▶ | my ( $self, $stash ) = @_; | ||||||||
|
Subroutine
process: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||
| 14 | |||||||||||
| 15 | 0 | ▶ | if( my ( $date_str, $msg ) = $stash->{'message'} =~ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 16 | /^(... {1,2}\d{1,2} \d{2}:\d{2}:\d{2}) (.+)$/) { | ||||||||||
| 17 | 0 | my $time = Time::Piece->strptime($date_str, "%b %e %H:%M:%S"); | |||||||||
| 18 | 0 | my $now = Time::Piece->new; | |||||||||
| 19 | |||||||||||
| 20 | # guess year | ||||||||||
| 21 | 0 | ▶ | if( $time->mon > $now->mon ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 22 | # Time::Piece->year is ro :-/ | ||||||||||
| 23 | 0 | $time->[5] = $now->[5] - 1; | |||||||||
| 24 | } else { | ||||||||||
| 25 | 0 | $time->[5] = $now->[5]; | |||||||||
| 26 | } | ||||||||||
| 27 | |||||||||||
| 28 | 0 | $stash->{'time'} = $time; | |||||||||
| 29 | 0 | $stash->{'message'} = $msg; | |||||||||
| 30 | } | ||||||||||
| 31 | |||||||||||
| 32 | 0 | ▶ | if( my ( $date_str, $msg ) = $stash->{'message'} =~ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:[\+\-](?:\d{2}):(?:\d{2})|Z) (.+)$/) { | ||||||||||
| 34 | 0 | $stash->{'time'} = Time::Piece->strptime($date_str, "%Y-%m-%dT%H:%M:%S%z"); | |||||||||
| 35 | 0 | $stash->{'message'} = $msg; | |||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | 0 | ▶ | if( my ( $host, $program, $pid, $msg ) = $stash->{'message'} =~ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | /^(\S+) ([^[]+)\[([^\]]+)\]: (.+)$/) { | ||||||||||
| 40 | 0 | $stash->{'host'} = $host; | |||||||||
| 41 | 0 | $self->incr_one('by_host', $host); | |||||||||
| 42 | 0 | $stash->{'program'} = $program; | |||||||||
| 43 | 0 | $self->incr_one('by_program', $program); | |||||||||
| 44 | 0 | $stash->{'pid'} = $pid; | |||||||||
| 45 | 0 | $stash->{'message'} = $msg; | |||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | 0 | return; | |||||||||
| 49 | } | ||||||||||
| 50 | |||||||||||
| 51 | 1 | 1; | |||||||||
| 52 | |||||||||||
| 53 | __END__ | ||||||||||
| 54 | |||||||||||
| 55 | =pod | ||||||||||
| 56 | |||||||||||
| 57 | =encoding UTF-8 | ||||||||||
| 58 | |||||||||||
| 59 | =head1 NAME | ||||||||||
| 60 | |||||||||||
| 61 | Log::Saftpresse::Plugin::SyslogFile - plugin to parse syslog logfile format | ||||||||||
| 62 | |||||||||||
| 63 | =head1 VERSION | ||||||||||
| 64 | |||||||||||
| 65 | version 1.5 | ||||||||||
| 66 | |||||||||||
| 67 | =head1 AUTHOR | ||||||||||
| 68 | |||||||||||
| 69 | Markus Benning <ich@markusbenning.de> | ||||||||||
| 70 | |||||||||||
| 71 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 72 | |||||||||||
| 73 | This software is Copyright (c) 1998 by James S. Seymour, 2015 by Markus Benning. | ||||||||||
| 74 | |||||||||||
| 75 | This is free software, licensed under: | ||||||||||
| 76 | |||||||||||
| 77 | The GNU General Public License, Version 2, June 1991 | ||||||||||
| 78 | |||||||||||
| 79 | =cut | ||||||||||