line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Log::Saftpresse::Analyzer; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
4
|
use Moose; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
6
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# ABSTRACT: class to analyze log messages |
6
|
|
|
|
|
|
|
our $VERSION = '1.5'; # VERSION |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
4572
|
use Log::Saftpresse::Notes; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
9
|
1
|
|
|
1
|
|
362
|
use Log::Saftpresse::Counters; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
26
|
|
10
|
1
|
|
|
1
|
|
4
|
use Log::Saftpresse::Log4perl; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
352
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
extends 'Log::Saftpresse::PluginContainer'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has 'notes' => ( |
15
|
|
|
|
|
|
|
is => 'ro', isa => 'Log::Saftpresse::Notes', lazy => 1, |
16
|
|
|
|
|
|
|
default => sub { Log::Saftpresse::Notes->new; }, |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has 'stats' => ( |
20
|
|
|
|
|
|
|
is => 'ro', isa => 'Log::Saftpresse::Counters', lazy => 1, |
21
|
|
|
|
|
|
|
default => sub { Log::Saftpresse::Counters->new; }, |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub process_message { |
25
|
0
|
|
|
0
|
0
|
|
my ( $self, $msg ) = @_; |
26
|
0
|
|
|
|
|
|
my $stash = { |
27
|
|
|
|
|
|
|
'message' => $msg, |
28
|
|
|
|
|
|
|
}; |
29
|
0
|
|
|
|
|
|
$self->process_event( $stash ); |
30
|
0
|
|
|
|
|
|
return; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub process_event { |
34
|
0
|
|
|
0
|
0
|
|
my ( $self, $stash ) = @_; |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
foreach my $plugin ( @{$self->plugins} ) { |
|
0
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
my $ret; |
38
|
0
|
|
|
|
|
|
eval { |
39
|
0
|
|
|
|
|
|
$ret = $plugin->process( $stash, $self->notes ); |
40
|
|
|
|
|
|
|
}; |
41
|
0
|
0
|
|
|
|
|
if( $@ ) { |
42
|
0
|
|
|
|
|
|
$log->error('plugin '.$plugin->name.' failed: '.$@); |
43
|
|
|
|
|
|
|
} |
44
|
0
|
0
|
0
|
|
|
|
if( defined $ret && $ret eq 'next') { |
45
|
0
|
|
|
|
|
|
last; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
0
|
|
|
|
|
|
$self->stats->incr_one('events'); |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
return; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub get_counters { |
54
|
0
|
|
|
0
|
0
|
|
my ( $self, $name ) = @_; |
55
|
0
|
|
|
|
|
|
my $plugin = $self->get_plugin( $name ); |
56
|
0
|
0
|
|
|
|
|
if( defined $plugin ) { |
57
|
0
|
|
|
|
|
|
return( $plugin->counters ); |
58
|
|
|
|
|
|
|
} |
59
|
0
|
|
|
|
|
|
return; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub get_all_counters { |
63
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
64
|
0
|
|
|
|
|
|
my %values; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
%values = map { |
67
|
0
|
|
|
|
|
|
$_->name => $_->counters |
68
|
0
|
|
|
|
|
|
} @{$self->plugins}; |
|
0
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
return \%values; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
__END__ |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=pod |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=encoding UTF-8 |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 NAME |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Log::Saftpresse::Analyzer - class to analyze log messages |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 VERSION |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
version 1.5 |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 AUTHOR |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Markus Benning <ich@markusbenning.de> |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
This software is Copyright (c) 1998 by James S. Seymour, 2015 by Markus Benning. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
This is free software, licensed under: |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
The GNU General Public License, Version 2, June 1991 |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=cut |