Scrappy::Logger(3pm)
π Scrappy::Logger π
okay bestie, gather round, because this is Scrappy::Logger β the Scrappy Scraper Event Logging module, a.k.a. the little diary your scraper writes in. it's version 0.94112090 and it lives in the Perl docs as a 3pm page, so like, it's a library, not a command. no cap. π
β¨ NAME β¨
Scrappy::Logger β Scrappy Scraper Event Logging π
πΈ VERSION πΈ
version 0.94112090 β yes that's the whole number, she's specific like that. β¨
π¦ SYNOPSIS π¦
here's the vibe, copy-paste and go:
#!/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 hands you YAML-Based event-log handling for recording the events you bump into while you're out here using the Scrappy framework. it's giving "my scraper keeps a receipts folder and every receipt is YAML." iconic. π«Ά
π ATTRIBUTES π
the following is a list of object attributes available with every Scrappy::Logger instance. every single one, we're not skipping. π
auto_saveβ this attribute is a boolean, and it decides whether your event data gets auto-saved to the log file whenever it updates. turn it off and you're on your own, bestie, you'll have to write explicitly.
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β this attribute gets/sets the filename of the current event-log file. it's literally just "which file are we yapping into right now."
my $logger = Scrappy::Logger->new;
$logger->load('scraper.log');
$logger->write('scraper.log.bak');
$logger->file('scraper.log');
verboseβ this attribute is a boolean and it tells the logger to write very detailed logs. she's not being vague, she's being thorough. main character energy fr fr.
my $logger = Scrappy::Logger->new;
$logger->verbose(1);
π METHODS π
β load β
the load method reads in an event-log file, and it returns its data in the structure it was saved-in. it gives back exactly what you gave it. periodt.
my $logger = Scrappy::Logger->new;
my $data = $logger->load('scraper.log');
β timestamp β
the timestamp method returns the current date/timestamp in string form. and when you feed it a properly formatted date/timestamp, it hands you back a corresponding DateTime object instead. glow-up incoming. β¨
my $logger = Scrappy::Logger->new;
my $date = $logger->timestamp;
my $dt = $logger->timestamp($date);
β info β
the info method captures informational events and returns the event data. just vibes, but logged.
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 captures warning events and returns the event data. like, hmm, something's a little off bestie. π
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 captures error events and returns the event data. this is the "it's so over" branch of the log. π
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 captures custom events and returns the event data. your app, your rules, your little label. π
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 writes-out an event-log file. this is the "hitting send" of the whole operation. π«Ά
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 <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. slay, go forth and remix. π
no cap, that's the whole page, bestie β you ate. π
perl v5.34.0 Β· 2022-06-17 β that's the source/version and the date, right there in the cute sign-off, so we're not leaving the footer out. π bye pookie! πΈ
π¦ where this page comes from
- debian bookworm: libscrappy-perl 0.94112090-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libscrappy-perl 0.94112090-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libscrappy-perl 0.94112090-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libscrappy-perl 0.94112090-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libscrappy-perl 0.94112090-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms