Saftpresse/Plugin/SyslogFile.pm

filter: Statementstmt 31.0% 9 / 29 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 2 / 3 Podpod 100% 1 / 1 totaltotal 29.2% 12 / 41 SCAR 27.6
CC
5
Cov
24%
process
30.0
BEGIN
1.0
BEGIN
1.0
CRAP 15.8
« Saftpresse/Log4perl.pm ↑ Summary Saftpresse/Input/FileTail.pm »
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
BranchTrueFalseTotal
if (() = $stash->{"message"} =~ /^(... {1,2}\d{1,2} \d{2}:\d{2}:\d{2}) (.+)$/) 0 0 0
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
BranchTrueFalseTotal
if ($time->mon > $now->mon) { } 0 0 0
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
BranchTrueFalseTotal
if (() = $stash->{"message"} =~ /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:[\+\-](?:\d{2}):(?:\d{2})|Z) (.+)$/) 0 0 0
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
BranchTrueFalseTotal
if (() = $stash->{"message"} =~ /^(\S+) ([^[]+)\[([^\]]+)\]: (.+)$/) 0 0 0
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
« Saftpresse/Log4perl.pm ↑ Summary Saftpresse/Input/FileTail.pm »