VERSION
version 0.94112090SYNOPSIS
#!/usr/bin/perl
use Scrappy::Logger;
my $logger = Scrappy::Logger->new;
-f 'scraper.log' ?
$logger->load('scraper.log');
$logger->write('scraper.log');
$logger->stash('foo' => 'bar');
$logger->stash('abc' => [('a'..'z')]);
DESCRIPTION
Scrappy::Logger provides YAML-Based event-log handling for recording events encountered using the Scrappy framework.ATTRIBUTES
The following is a list of object attributes available with every Scrappy::Logger instance.auto_save
The auto_save attribute is a boolean that determines whether event data is automatically saved to the log file on update.
my $logger = Scrappy::Logger->new; $logger->load('scraper.log'); # turn auto-saving off $logger->auto_save(0); $logger->event('...', 'yada yada yada'); $logger->write; # explicit write
file
The file attribute gets/sets the filename of the current event-log file.
my $logger = Scrappy::Logger->new; $logger->load('scraper.log'); $logger->write('scraper.log.bak'); $logger->file('scraper.log');
verbose
The verbose attribute is a boolean that instructs the logger to write very detailed logs.
my $logger = Scrappy::Logger->new; $logger->verbose(1);
METHODS
load
The load method is used to read-in an event-log file, it returns its data in the structure it was saved-in.
my $logger = Scrappy::Logger->new; my $data = $logger->load('scraper.log');
timestamp
The timestamp method returns the current date/timestamp in string form. When supplied a properly formatted date/timestamp this method returns a corresponding DateTime object.
my $logger = Scrappy::Logger->new; my $date = $logger->timestamp; my $dt = $logger->timestamp($date);
info
The info method is used to capture informational events and returns the event data.
my $logger = Scrappy::Logger->new; my %data = (foo => 'bar', baz => 'xyz'); my $event = $logger->info('This is an informational message', %data); $logger->info('This is an informational message');
warn
The warn method is used to capture warning events and returns the event data.
my $logger = Scrappy::Logger->new; my %data = (foo => 'bar', baz => 'xyz'); my $event = $logger->warn('This is a warning message', %data); $logger->info('This is an warning message');
error
The error method is used to capture error events and returns the event data.
my $logger = Scrappy::Logger->new; my %data = (foo => 'bar', baz => 'xyz'); my $event = $logger->error('This is a n error message', %data); $logger->info('This is an error message');
event
The event method is used to capture custom events and returns the event data.
my $logger = Scrappy::Logger->new; my %data = (foo => 'bar', baz => 'xyz'); my $event = $logger->event('myapp', 'This is a user-defined message', %data); $logger->event('myapp', 'This is a user-defined message');
write
The write method is used to write-out an event-log file.
my $logger = Scrappy::Logger->new; $logger->info('This is very cool', 'foo' => 'bar'); $logger->warn('Somethin aint right here'); $logger->error('It broke, I cant believe it broke'); $logger->write('scraper.log');
AUTHOR
Al Newkirk <[email protected]>COPYRIGHT AND LICENSE
This software is copyright (c) 2010 by awncorp.This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.