Saftpresse/Analyzer.pm

filter: Statementstmt 36.9% 17 / 46 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 40.0% 4 / 10 Podpod 0.0% 0 / 4 totaltotal 29.5% 21 / 71 SCAR 28.8
CC
6
Cov
31%
process_event
30.0
get_counters
6.0
__ANON__
2.0
CRAP 17.9
« Saftpresse/Plugin/Postfix/Messages.pm ↑ Summary Saftpresse/PluginContainer.pm »
1 package Log::Saftpresse::Analyzer;
2  
3 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 # ABSTRACT: class to analyze log messages
6 1 our $VERSION = '1.5'; # VERSION
7  
8 1 ▶use Log::Saftpresse::Notes;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Log::Saftpresse::Counters;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Log::Saftpresse::Log4perl;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 extends 'Log::Saftpresse::PluginContainer';
13  
14 has 'notes' => (
15 is => 'ro', isa => 'Log::Saftpresse::Notes', lazy => 1,
16 0 ▶ default => sub { Log::Saftpresse::Notes->new; },
Subroutine __ANON__: not called CC=1 SCAR=6.9
17 1 );
18  
19 has 'stats' => (
20 is => 'ro', isa => 'Log::Saftpresse::Counters', lazy => 1,
21 0 ▶ default => sub { Log::Saftpresse::Counters->new; },
Subroutine __ANON__: not called CC=1 SCAR=6.9
22 1 );
23  
24 sub process_message {
25 0 ▶ my ( $self, $msg ) = @_;
Subroutine process_message: not called CC=1 SCAR=6.9
Pod undocumented
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 ▶ my ( $self, $stash ) = @_;
Subroutine process_event: not called CC=5 SCAR=34.0
Pod undocumented
35
36 0 foreach my $plugin ( @{$self->plugins} ) {
37 0 my $ret;
38 0 eval {
39 0 $ret = $plugin->process( $stash, $self->notes );
40 };
41 0 ▶ if( $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
42 0 $log->error('plugin '.$plugin->name.' failed: '.$@);
43 }
44 0 ▶ if( defined $ret && $ret eq 'next') {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ret and $ret eq "next") 0 0 0
Condition0%0/3
defined $ret and $ret eq "next"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $ret and $ret eq "next"
defined $ret $ret eq "next"
Truth table0%0/3
A and B
A= defined $retB= $ret eq "next"
ABresult
0X0
100
111
45 0 last;
46 }
47 }
48 0 $self->stats->incr_one('events');
49  
50 0 return;
51 }
52  
53 sub get_counters {
54 0 ▶ my ( $self, $name ) = @_;
Subroutine get_counters: not called CC=2 SCAR=17.9
Pod undocumented
55 0 my $plugin = $self->get_plugin( $name );
56 0 ▶ if( defined $plugin ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $plugin) 0 0 0
57 0 return( $plugin->counters );
58 }
59 0 return;
60 }
61  
62 sub get_all_counters {
63 0 ▶ my $self = shift;
Subroutine get_all_counters: not called CC=1 SCAR=6.9
Pod undocumented
64 0 my %values;
65  
66 %values = map {
67 0 $_->name => $_->counters
68 0 } @{$self->plugins};
69  
70 0 return \%values;
71 }
72  
73 1 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
« Saftpresse/Plugin/Postfix/Messages.pm ↑ Summary Saftpresse/PluginContainer.pm »