Venus::Log
Log Class
Log Class for Perl 5
method: debug method: error method: fatal method: info method: input method: output method: string method: trace method: warn method: write
package main;
use Venus::Log;
my $log = Venus::Log->new;
# $log->trace(time, 'Something failed!');
# "0000000000 Something failed!"
# $log->error(time, 'Something failed!');
# "0000000000 Something failed!"
This package provides methods for logging information using various log levels. The default log level is trace. Acceptable log levels are trace, debug, info, warn, error, and fatal, and the set log level will handle events for its level and any preceding levels in the order specified.
Venus::Kind::Utility
Venus::Role::Buildable
The handler attribute holds the callback that handles logging. The handler is passed the log level and the log messages.
handler(coderef $code) (coderef)
{ since => '1.68', }
=example-1 handler
# given: synopsis
package main;
my $handler = $log->handler;
my $events = [];
$handler = $log->handler(sub{shift; push @$events, [@_]});
The level attribute holds the current log level. Valid log levels are trace, debug, info, warn, error and fatal, and will emit log messages in that order. Invalid log levels effectively disable logging.
level(string $name) (string)
{ since => '1.68', }
=example-1 level
# given: synopsis
package main;
my $level = $log->level;
# "trace"
$level = $log->level('fatal');
# "fatal"
The separator attribute holds the value used to join multiple log message arguments.
separator(any $data) (any)
{ since => '1.68', }
=example-1 separator
# given: synopsis
package main;
my $separator = $log->separator;
# ""
$separator = $log->separator("\n");
# "\n"
The debug method logs debug information and returns the invocant.
debug(string @data) (Venus::Log)
{ since => '1.68', }
=example-1 debug
# given: synopsis
package main;
# $log = $log->debug(time, 'Something failed!');
# "0000000000 Something failed!"
The error method logs error information and returns the invocant.
error(string @data) (Venus::Log)
{ since => '1.68', }
=example-1 error
# given: synopsis
package main;
# $log = $log->error(time, 'Something failed!');
# "0000000000 Something failed!"
The fatal method logs fatal information and returns the invocant.
fatal(string @data) (Venus::Log)
{ since => '1.68', }
=example-1 fatal
# given: synopsis
package main;
# $log = $log->fatal(time, 'Something failed!');
# "0000000000 Something failed!"
The info method logs info information and returns the invocant.
info(string @data) (Venus::Log)
{ since => '1.68', }
=example-1 info
# given: synopsis
package main;
# $log = $log->info(time, 'Something failed!');
# "0000000000 Something failed!"
The input method returns the arguments provided to the log level methods, to the "output", and can be overridden by subclasses.
input(string @data) (string)
{ since => '1.68', }
=example-1 input
# given: synopsis
package main;
my @input = $log->input(1, 'Something failed!');
# (1, 'Something failed!')
The new method returns a new instance of this package.
new(string $level | any %args | hashref $args) (Venus::Log)
{ since => '1.68', }
=example-1 new
package main;
use Venus::Log;
my $log = Venus::Log->new;
# bless(..., "Venus::Log")
# $log->level;
# "trace"
The output method returns the arguments returned by the "input" method, to the log handler, and can be overridden by subclasses.
output(string @data) (string)
{ since => '1.68', }
=example-1 output
# given: synopsis
package main;
my $output = $log->output(time, 'Something failed!');
# "0000000000 Something failed!"
The string method returns a stringified representation of any argument provided and is used by the "output" method.
string(any $data) (string)
{ since => '1.68', }
=example-1 string
# given: synopsis
package main;
my $string = $log->string;
# ""
The trace method logs trace information and returns the invocant.
trace(string @data) (Venus::Log)
{ since => '1.68', }
=example-1 trace
# given: synopsis
package main;
# $log = $log->trace(time, 'Something failed!');
# "0000000000 Something failed!"
The warn method logs warn information and returns the invocant.
warn(string @data) (Venus::Log)
{ since => '1.68', }
=example-1 warn
# given: synopsis
package main;
# $log = $log->warn(time, 'Something failed!');
# "0000000000 Something failed!"
The write method invokes the log handler, i.e. "handler", and returns the invocant.
write(string $level, any @data) (Venus::Log)
{ since => '1.68', }
=example-1 write
# given: synopsis
package main;
# $log = $log->write('info', time, 'Something failed!');
# bless(..., "Venus::Log")
t/Venus.t: present: authors t/Venus.t: present: license
62 POD Errors
The following errors were encountered while parsing the POD:
- Around line 13:
Unknown directive: =name
- Around line 21:
Unknown directive: =tagline
- Around line 29:
Unknown directive: =abstract
- Around line 37:
Unknown directive: =includes
- Around line 54:
Unknown directive: =synopsis
- Around line 87:
Unknown directive: =description
- Around line 98:
Unknown directive: =inherits
- Around line 106:
Unknown directive: =integrates
- Around line 114:
Unknown directive: =attribute
- Around line 119:
Unknown directive: =signature
- Around line 123:
Unknown directive: =metadata
- Around line 151:
Unknown directive: =attribute
- Around line 157:
Unknown directive: =signature
- Around line 161:
Unknown directive: =metadata
- Around line 191:
Unknown directive: =attribute
- Around line 195:
Unknown directive: =signature
- Around line 199:
Unknown directive: =metadata
- Around line 229:
Unknown directive: =method
- Around line 233:
Unknown directive: =signature
- Around line 237:
Unknown directive: =metadata
- Around line 280:
=cut found outside a pod block. Skipping to next block.
- Around line 296:
Unknown directive: =method
- Around line 300:
Unknown directive: =signature
- Around line 304:
Unknown directive: =metadata
- Around line 347:
=cut found outside a pod block. Skipping to next block.
- Around line 363:
Unknown directive: =method
- Around line 367:
Unknown directive: =signature
- Around line 371:
Unknown directive: =metadata
- Around line 414:
=cut found outside a pod block. Skipping to next block.
- Around line 430:
Unknown directive: =method
- Around line 434:
Unknown directive: =signature
- Around line 438:
Unknown directive: =metadata
- Around line 481:
=cut found outside a pod block. Skipping to next block.
- Around line 497:
Unknown directive: =method
- Around line 502:
Unknown directive: =signature
- Around line 506:
Unknown directive: =metadata
- Around line 532:
Unknown directive: =method
- Around line 536:
Unknown directive: =signature
- Around line 540:
Unknown directive: =metadata
- Around line 585:
=cut found outside a pod block. Skipping to next block.
- Around line 610:
=cut found outside a pod block. Skipping to next block.
- Around line 621:
Unknown directive: =method
- Around line 626:
Unknown directive: =signature
- Around line 630:
Unknown directive: =metadata
- Around line 656:
Unknown directive: =method
- Around line 661:
Unknown directive: =signature
- Around line 665:
Unknown directive: =metadata
- Around line 701:
=cut found outside a pod block. Skipping to next block.
- Around line 721:
=cut found outside a pod block. Skipping to next block.
- Around line 741:
=cut found outside a pod block. Skipping to next block.
- Around line 752:
Unknown directive: =method
- Around line 756:
Unknown directive: =signature
- Around line 760:
Unknown directive: =metadata
- Around line 803:
=cut found outside a pod block. Skipping to next block.
- Around line 819:
Unknown directive: =method
- Around line 823:
Unknown directive: =signature
- Around line 827:
Unknown directive: =metadata
- Around line 870:
=cut found outside a pod block. Skipping to next block.
- Around line 886:
Unknown directive: =method
- Around line 890:
Unknown directive: =signature
- Around line 894:
Unknown directive: =metadata
- Around line 927:
Unknown directive: =partials