GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Scrappy::Logger(3) User Contributed Perl Documentation Scrappy::Logger(3)

Scrappy::Logger - Scrappy Scraper Event Logging

version 0.94112090

    #!/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')]);

Scrappy::Logger provides YAML-Based event-log handling for recording events encountered using the Scrappy framework.

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);

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');

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);

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');

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');

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');

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');

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');

Al Newkirk <awncorp@cpan.org>

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.

2011-07-28 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.