line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Devel::Events::Filter::Stamp; |
4
|
2
|
|
|
2
|
|
27216
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
with qw/Devel::Events::Filter/; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use Time::HiRes qw/time/; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub filter_event { |
11
|
|
|
|
|
|
|
my ( $self, $type, @data ) = @_; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
return ( |
14
|
|
|
|
|
|
|
$type, |
15
|
|
|
|
|
|
|
$self->stamp_data, |
16
|
|
|
|
|
|
|
@data, |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $i; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub stamp_data { |
23
|
|
|
|
|
|
|
return ( |
24
|
|
|
|
|
|
|
id => ++$i, |
25
|
|
|
|
|
|
|
time => time(), # DateTime eats HiRes time =D |
26
|
|
|
|
|
|
|
pid => $$, |
27
|
|
|
|
|
|
|
( defined &Thread::tid # Only if threads are loaded |
28
|
|
|
|
|
|
|
? ( thread_id => Thread->self->tid ) |
29
|
|
|
|
|
|
|
: () ), |
30
|
|
|
|
|
|
|
) |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
__PACKAGE__; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
__END__ |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=pod |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 NAME |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Devel::Events::Filter::Stamp - Add time/context stamping to events |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 SYNOPSIS |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
use Devel::Events::Filter::Stamp; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
my $filter = Devel::Events::Filter::Stamp->new( |
48
|
|
|
|
|
|
|
handler => $handler, |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Generator::Blah->new( handler => $filter ); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 DESCRIPTION |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
This event filter will add timing and context information to the event. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
The parameters are prepended so that upon hash assignment the event generator |
58
|
|
|
|
|
|
|
will get precedence. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 METHODS |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=over 4 |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=item filter_event @event |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Prepends the output of C<stamp_data> to C<@event> |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=item stamp_data |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Returns the new fields, as detailed in L</STAMP DATA> |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=back |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 STAMP DATA |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=over 4 |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item time |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
A fractional timestamp, from L<Time::HiRes>. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Suitable for passing to L<DateTime> unaltered. Other modules may require application of C<int>. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=item pid |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
The value of C<$$> |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item thread_id |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Only included if threads are in use. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
The current thread ID. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=back |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=cut |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|