.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Scrappy::Logger 3pm" .TH Scrappy::Logger 3pm "2021-01-07" "perl v5.32.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Scrappy::Logger \- Scrappy Scraper Event Logging .SH "VERSION" .IX Header "VERSION" version 0.94112090 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& #!/usr/bin/perl \& use Scrappy::Logger; \& \& my $logger = Scrappy::Logger\->new; \& \& \-f \*(Aqscraper.log\*(Aq ? \& $logger\->load(\*(Aqscraper.log\*(Aq); \& $logger\->write(\*(Aqscraper.log\*(Aq); \& \& $logger\->stash(\*(Aqfoo\*(Aq => \*(Aqbar\*(Aq); \& $logger\->stash(\*(Aqabc\*(Aq => [(\*(Aqa\*(Aq..\*(Aqz\*(Aq)]); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Scrappy::Logger provides YAML-Based event-log handling for recording events encountered using the Scrappy framework. .SS "\s-1ATTRIBUTES\s0" .IX Subsection "ATTRIBUTES" The following is a list of object attributes available with every Scrappy::Logger instance. .PP \fIauto_save\fR .IX Subsection "auto_save" .PP The auto_save attribute is a boolean that determines whether event data is automatically saved to the log file on update. .PP .Vb 1 \& my $logger = Scrappy::Logger\->new; \& \& $logger\->load(\*(Aqscraper.log\*(Aq); \& \& # turn auto\-saving off \& $logger\->auto_save(0); \& $logger\->event(\*(Aq...\*(Aq, \*(Aqyada yada yada\*(Aq); \& $logger\->write; # explicit write .Ve .PP \fIfile\fR .IX Subsection "file" .PP The file attribute gets/sets the filename of the current event-log file. .PP .Vb 1 \& my $logger = Scrappy::Logger\->new; \& \& $logger\->load(\*(Aqscraper.log\*(Aq); \& $logger\->write(\*(Aqscraper.log.bak\*(Aq); \& $logger\->file(\*(Aqscraper.log\*(Aq); .Ve .PP \fIverbose\fR .IX Subsection "verbose" .PP The verbose attribute is a boolean that instructs the logger to write very detailed logs. .PP .Vb 2 \& my $logger = Scrappy::Logger\->new; \& $logger\->verbose(1); .Ve .SH "METHODS" .IX Header "METHODS" .SS "load" .IX Subsection "load" The load method is used to read-in an event-log file, it returns its data in the structure it was saved-in. .PP .Vb 2 \& my $logger = Scrappy::Logger\->new; \& my $data = $logger\->load(\*(Aqscraper.log\*(Aq); .Ve .SS "timestamp" .IX Subsection "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. .PP .Vb 3 \& my $logger = Scrappy::Logger\->new; \& my $date = $logger\->timestamp; \& my $dt = $logger\->timestamp($date); .Ve .SS "info" .IX Subsection "info" The info method is used to capture informational events and returns the event data. .PP .Vb 3 \& my $logger = Scrappy::Logger\->new; \& my %data = (foo => \*(Aqbar\*(Aq, baz => \*(Aqxyz\*(Aq); \& my $event = $logger\->info(\*(AqThis is an informational message\*(Aq, %data); \& \& $logger\->info(\*(AqThis is an informational message\*(Aq); .Ve .SS "warn" .IX Subsection "warn" The warn method is used to capture warning events and returns the event data. .PP .Vb 3 \& my $logger = Scrappy::Logger\->new; \& my %data = (foo => \*(Aqbar\*(Aq, baz => \*(Aqxyz\*(Aq); \& my $event = $logger\->warn(\*(AqThis is a warning message\*(Aq, %data); \& \& $logger\->info(\*(AqThis is an warning message\*(Aq); .Ve .SS "error" .IX Subsection "error" The error method is used to capture error events and returns the event data. .PP .Vb 3 \& my $logger = Scrappy::Logger\->new; \& my %data = (foo => \*(Aqbar\*(Aq, baz => \*(Aqxyz\*(Aq); \& my $event = $logger\->error(\*(AqThis is a n error message\*(Aq, %data); \& \& $logger\->info(\*(AqThis is an error message\*(Aq); .Ve .SS "event" .IX Subsection "event" The event method is used to capture custom events and returns the event data. .PP .Vb 3 \& my $logger = Scrappy::Logger\->new; \& my %data = (foo => \*(Aqbar\*(Aq, baz => \*(Aqxyz\*(Aq); \& my $event = $logger\->event(\*(Aqmyapp\*(Aq, \*(AqThis is a user\-defined message\*(Aq, %data); \& \& $logger\->event(\*(Aqmyapp\*(Aq, \*(AqThis is a user\-defined message\*(Aq); .Ve .SS "write" .IX Subsection "write" The write method is used to write-out an event-log file. .PP .Vb 1 \& my $logger = Scrappy::Logger\->new; \& \& $logger\->info(\*(AqThis is very cool\*(Aq, \*(Aqfoo\*(Aq => \*(Aqbar\*(Aq); \& $logger\->warn(\*(AqSomethin aint right here\*(Aq); \& $logger\->error(\*(AqIt broke, I cant believe it broke\*(Aq); \& \& $logger\->write(\*(Aqscraper.log\*(Aq); .Ve .SH "AUTHOR" .IX Header "AUTHOR" Al Newkirk .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2010 by awncorp. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.