| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Log::Saftpresse::Plugin::LimitDay; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1098
|
use Moose; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
26
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# ABSTRACT: plugin to skip messages not from today or yesterday |
|
6
|
|
|
|
|
|
|
our $VERSION = '1.4'; # VERSION |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
extends 'Log::Saftpresse::Plugin'; |
|
9
|
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
4230
|
use Time::Piece; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
8
|
|
|
11
|
1
|
|
|
1
|
|
61
|
use Time::Seconds; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
266
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has 'day' => ( is => 'rw', isa => 'Maybe[Str]' ); |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has 'now' => ( is => 'rw', isa => 'Time::Piece', lazy => 1, |
|
16
|
|
|
|
|
|
|
default => sub { Time::Piece->new }, |
|
17
|
|
|
|
|
|
|
); |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has 'yesterday' => ( is => 'rw', isa => 'Time::Piece', lazy => 1, |
|
20
|
|
|
|
|
|
|
default => sub { |
|
21
|
|
|
|
|
|
|
return Time::Piece->new - ONE_DAY; |
|
22
|
|
|
|
|
|
|
}, |
|
23
|
|
|
|
|
|
|
); |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub is_yesterday { |
|
26
|
0
|
|
|
0
|
0
|
|
my ( $self, $time ) = @_; |
|
27
|
0
|
0
|
|
|
|
|
if( $self->yesterday->ymd eq $time->ymd ) { |
|
28
|
0
|
|
|
|
|
|
return( 1 ); |
|
29
|
|
|
|
|
|
|
} |
|
30
|
0
|
|
|
|
|
|
return( 0 ); |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub is_today { |
|
34
|
0
|
|
|
0
|
0
|
|
my ( $self, $time ) = @_; |
|
35
|
0
|
0
|
|
|
|
|
if( $self->now->ymd eq $time->ymd ) { |
|
36
|
0
|
|
|
|
|
|
return( 1 ); |
|
37
|
|
|
|
|
|
|
} |
|
38
|
0
|
|
|
|
|
|
return( 0 ); |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub process { |
|
42
|
0
|
|
|
0
|
1
|
|
my ( $self, $stash ) = @_; |
|
43
|
0
|
|
|
|
|
|
my $day = $self->day; |
|
44
|
0
|
|
|
|
|
|
my $time = $stash->{'time'}; |
|
45
|
0
|
0
|
|
|
|
|
if( ! defined $time ) { |
|
46
|
0
|
|
|
|
|
|
return; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
0
|
0
|
0
|
|
|
|
if( $day eq 'today' && ! $self->is_today($time) ) { |
|
|
|
0
|
0
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
return('next'); |
|
51
|
|
|
|
|
|
|
} elsif( $day eq 'yesterday' && ! $self->is_yesterday($time) ) { |
|
52
|
0
|
|
|
|
|
|
return('next'); |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
return; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
__END__ |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=pod |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=encoding UTF-8 |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 NAME |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Log::Saftpresse::Plugin::LimitDay - plugin to skip messages not from today or yesterday |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 VERSION |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
version 1.4 |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 AUTHOR |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Markus Benning <ich@markusbenning.de> |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
This software is Copyright (c) 1998 by James S. Seymour, 2015 by Markus Benning. |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
This is free software, licensed under: |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
The GNU General Public License, Version 2, June 1991 |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut |