Timed::Logger - store events for later analysis.
Version 0.0.6
use Timed::Logger; my $logger = Timed::Logger->new; my $log_entry = $logger->start; #... #some lengthly operation #... $logger->finish($entry, { description => 'long operation' }); #... foreach my $entry ($logger->log->{default}) { printf("Operation %s took $.4f s", $entry->data->{description}, $entry->elapsed); } printf("Total time: $.4f s", $logger->elapsed_total); printf("Total time in default bucket: $.4f s", $logger->elapsed_total('default'));
Timed::Logger allows one to log events along with amount if time that event took. This can be useful for debugging and profiling purposes. See Plack::Middleware::Debug::Timed::Logger for usage example.
Sometimes you want to break your events into different types and anaylze them separately. This can be achieved using buckets:
my $log_entry = $logger->start('DB'); #... #some DB operation #... $logger->finish($entry, { description => 'long operation' }); my $log_entry = $logger->start('some'); #... #some other type of operation #... $logger->finish($entry, { description => 'long operation' });
By default bucket named 'default' is used.
This attribute contains a log gathered so far. It is organized as an hashref of arrayref of entries. Keys in a hash represent buckets. Each entry has a Timed::Logger::Entry type.
Create a new Timed::Logger.
Start a new event. Returns new Timed::Logger::Entry. One can specify bucket to use, otherwise 'default' is used.
Save current into log. If optional $data is set it is stored in Timed::Logger::Entry data attribute.
Calculates total time for all events (by default) or for given bucket if one is provided.
Plack::Middleware::Timed::Logger, Plack::Middleware::Debug::Timed::Logger, Timed::Logger::Dancer::AdoptPlack
Nikolay Martynov, <kolya at cpan.org>
<kolya at cpan.org>
Please report any bugs or feature requests to bug-timed-logger at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Timed-Logger. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-timed-logger at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Timed::Logger
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Timed-Logger
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Timed-Logger
CPAN Ratings
http://cpanratings.perl.org/d/Timed-Logger
Search CPAN
http://search.cpan.org/dist/Timed-Logger/
Logan Bell and Belden Lyman.
Copyright 2013 Nikolay Martynov and Shutterstock Inc (http://shutterstock.com). All rights reserved.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
To install Timed::Logger, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Timed::Logger
CPAN shell
perl -MCPAN -e shell install Timed::Logger
For more information on module installation, please visit the detailed CPAN module installation guide.