| Devel-Events documentation | Contained in the Devel-Events distribution. |
Devel::Events::Filter::Stamp - Add time/context stamping to events
use Devel::Events::Filter::Stamp; my $filter = Devel::Events::Filter::Stamp->new( handler => $handler, ); Generator::Blah->new( handler => $filter );
This event filter will add timing and context information to the event.
The parameters are prepended so that upon hash assignment the event generator will get precedence.
Prepends the output of stamp_data to @event
Returns the new fields, as detailed in STAMP DATA
A fractional timestamp, from Time::HiRes.
Suitable for passing to DateTime unaltered. Other modules may require application of int.
The value of $$
Only included if threads are in use.
The current thread ID.
| Devel-Events documentation | Contained in the Devel-Events distribution. |
#!/usr/bin/perl package Devel::Events::Filter::Stamp; use Moose; with qw/Devel::Events::Filter/; use Time::HiRes qw/time/; sub filter_event { my ( $self, $type, @data ) = @_; return ( $type, $self->stamp_data, @data, ); } my $i; sub stamp_data { return ( id => ++$i, time => time(), # DateTime eats HiRes time =D pid => $$, ( defined &Thread::tid # Only if threads are loaded ? ( thread_id => Thread->self->tid ) : () ), ) } __PACKAGE__; __END__