The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Scrappy::Logger - Scrappy Event Logging Mechanism

VERSION

version 0.9111110

SYNOPSIS

    #!/usr/bin/perl
    use Scrappy;

    my  $log = Scrappy::Logger->new;
        $log->write('log.yml');
        
        $scraper->info('captain log, star-date 1234');
        $scraper->info('captain log, star-date 5678', foo => 'bar');
        $scraper->warn('...');
        $scraper->error('...');

DESCRIPTION

Scrappy::Logger provides Scrappy with methods for logging event data within a easily readable log (YAML) files.

METHODS

load

The load method is used to read the specified log file.

    my  $log = Scrappy::Logger->new;
    my  $data = $log->load('log.yml');

timestamp

The timestamp method is used generate a current system date and time string for use with event logging.

    my  $log  = Scrappy::Logger->new;
    my  $date = $log->timestamp;
    print $date;
    
    my $datetime_object = $log->timestamp($date);

info

The info method is used to log an information event to the event log.

    my  $log  = Scrappy::Logger->new;
    my  %data = ( foo => 'bar');
        $log->info('Something strange happened today', %data);

warn

The warn method is used to log a warning event to the event log.

    my  $log  = Scrappy::Logger->new;
    my  %data = ( foo => 'bar');
        $log->warn('Something strange happened today', %data);

error

The error method is used to log an error event to the event log.

    my  $log  = Scrappy::Logger->new;
    my  %data = ( foo => 'bar');
        $log->error('Something strange happened today', %data);

event

The event method is used to log an event to the event log.

    my  $log  = Scrappy::Logger->new;
    my  %data = ( foo => 'bar');
    my  $type = 'WTF';
        $log->event($type, 'Something strange happened today', %data);

write

The write method is used to write the specified log file. This happens automatically is a file is specified using either the load() or write() methods when events are recorded.

    my  $log = Scrappy::Logger->new;
        $log->write('log.yml');

AUTHOR

Al Newkirk <awncorp@cpan.org>

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.