| 1 | package Log::Saftpresse::Plugin::Role::CounterUtils; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use Moose::Role; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | # ABSTRACT: role for plugins to gather statistics/counters | ||||||||||||||||||||||||||||
| 6 | 1 | our $VERSION = '1.5'; # VERSION | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 1 | has 'per_host_counters' => ( is => 'rw', isa => 'Bool', default => 1 ); | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | sub _get_event_host { | ||||||||||||||||||||||||||||
| 11 | 0 | ▶ | my ( $self, $event ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_get_event_host: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 12 | 0 | ▶ | if( ! $self->per_host_counters ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 13 | 0 | return; | |||||||||||||||||||||||||||
| 14 | } | ||||||||||||||||||||||||||||
| 15 | 0 | ▶ | if( defined $event->{'host'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 16 | 0 | return( $event->{'host'}); | |||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||
| 18 | 0 | return 'empty'; | |||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | sub incr_host { | ||||||||||||||||||||||||||||
| 22 | 0 | ▶ | my ( $self, $event, @params ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
incr_host: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 23 | 0 | return $self->incr( ($self->_get_event_host($event)), @params ); | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | sub incr_host_one { | ||||||||||||||||||||||||||||
| 27 | 0 | ▶ | my ( $self, $event, @params ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
incr_host_one: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 28 | 0 | return $self->incr_one( ($self->_get_event_host($event)), @params ); | |||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | sub incr_host_max { | ||||||||||||||||||||||||||||
| 32 | 0 | ▶ | my ( $self, $event, @params ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
incr_host_max: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 33 | 0 | return $self->incr_max( ($self->_get_event_host($event)), @params ); | |||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | sub count_array_field_values { | ||||||||||||||||||||||||||||
| 37 | 0 | ▶ | my ( $self, $stash, $field ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
count_array_field_values: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 38 | 0 | ▶ | if( ! defined $stash->{$field} || ref($stash->{$field}) ne 'ARRAY' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $stash->{$field} or ref $stash->{$field} ne "ARRAY"
MC/DC0%0/2
not defined $stash->{$field} or ref $stash->{$field} ne "ARRAY"
not defined $stash->{$field}
ref $stash->{$field} ne "ARRAY"
Truth table0%0/3
not(A) or B
A= not defined $stash->{$field}B= ref $stash->{$field} ne "ARRAY"
| |||||||||||||||||||||||||||||
| 39 | 0 | return; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | 0 | foreach my $test ( @{$stash->{$field}} ) { | |||||||||||||||||||||||||||
| 42 | 0 | $self->incr_host_one($stash, $field, $test ); | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | 0 | return; | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | sub count_fields_value { | ||||||||||||||||||||||||||||
| 48 | 0 | ▶ | my ( $self, $stash, @fields ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
count_fields_value: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 49 | 0 | foreach my $field ( @fields ) { | |||||||||||||||||||||||||||
| 50 | 0 | ▶ | if( ! defined $stash->{$field} ) { next; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | 0 | $self->incr_host($stash, $field, $stash->{$field} ); | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | 0 | return; | |||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | sub count_fields_occur { | ||||||||||||||||||||||||||||
| 57 | 0 | ▶ | my ( $self, $stash, @fields ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
count_fields_occur: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 58 | 0 | foreach my $field ( @fields ) { | |||||||||||||||||||||||||||
| 59 | 0 | ▶ | if( ! defined $stash->{$field} ) { next; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 60 | 0 | $self->incr_host_one($stash, $field, $stash->{$field} ); | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | 0 | return; | |||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 1 | 1; | |||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | __END__ | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | =pod | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | =encoding UTF-8 | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | =head1 NAME | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | Log::Saftpresse::Plugin::Role::CounterUtils - role for plugins to gather statistics/counters | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | =head1 VERSION | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | version 1.5 | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | Markus Benning <ich@markusbenning.de> | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | This software is Copyright (c) 1998 by James S. Seymour, 2015 by Markus Benning. | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | This is free software, licensed under: | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | The GNU General Public License, Version 2, June 1991 | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | =cut | ||||||||||||||||||||||||||||