Venus::Log
Log Class
Log Class for Perl 5
method: debug method: error method: fatal method: info method: input method: output method: new 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 14:
Unknown directive: =name
- Around line 22:
Unknown directive: =tagline
- Around line 30:
Unknown directive: =abstract
- Around line 38:
Unknown directive: =includes
- Around line 56:
Unknown directive: =synopsis
- Around line 89:
Unknown directive: =description
- Around line 100:
Unknown directive: =inherits
- Around line 108:
Unknown directive: =integrates
- Around line 116:
Unknown directive: =attribute
- Around line 121:
Unknown directive: =signature
- Around line 125:
Unknown directive: =metadata
- Around line 153:
Unknown directive: =attribute
- Around line 159:
Unknown directive: =signature
- Around line 163:
Unknown directive: =metadata
- Around line 193:
Unknown directive: =attribute
- Around line 197:
Unknown directive: =signature
- Around line 201:
Unknown directive: =metadata
- Around line 231:
Unknown directive: =method
- Around line 235:
Unknown directive: =signature
- Around line 239:
Unknown directive: =metadata
- Around line 282:
=cut found outside a pod block. Skipping to next block.
- Around line 298:
Unknown directive: =method
- Around line 302:
Unknown directive: =signature
- Around line 306:
Unknown directive: =metadata
- Around line 349:
=cut found outside a pod block. Skipping to next block.
- Around line 365:
Unknown directive: =method
- Around line 369:
Unknown directive: =signature
- Around line 373:
Unknown directive: =metadata
- Around line 416:
=cut found outside a pod block. Skipping to next block.
- Around line 432:
Unknown directive: =method
- Around line 436:
Unknown directive: =signature
- Around line 440:
Unknown directive: =metadata
- Around line 483:
=cut found outside a pod block. Skipping to next block.
- Around line 499:
Unknown directive: =method
- Around line 504:
Unknown directive: =signature
- Around line 508:
Unknown directive: =metadata
- Around line 534:
Unknown directive: =method
- Around line 538:
Unknown directive: =signature
- Around line 542:
Unknown directive: =metadata
- Around line 587:
=cut found outside a pod block. Skipping to next block.
- Around line 612:
=cut found outside a pod block. Skipping to next block.
- Around line 623:
Unknown directive: =method
- Around line 628:
Unknown directive: =signature
- Around line 632:
Unknown directive: =metadata
- Around line 658:
Unknown directive: =method
- Around line 663:
Unknown directive: =signature
- Around line 667:
Unknown directive: =metadata
- Around line 703:
=cut found outside a pod block. Skipping to next block.
- Around line 723:
=cut found outside a pod block. Skipping to next block.
- Around line 743:
=cut found outside a pod block. Skipping to next block.
- Around line 754:
Unknown directive: =method
- Around line 758:
Unknown directive: =signature
- Around line 762:
Unknown directive: =metadata
- Around line 805:
=cut found outside a pod block. Skipping to next block.
- Around line 821:
Unknown directive: =method
- Around line 825:
Unknown directive: =signature
- Around line 829:
Unknown directive: =metadata
- Around line 872:
=cut found outside a pod block. Skipping to next block.
- Around line 888:
Unknown directive: =method
- Around line 892:
Unknown directive: =signature
- Around line 896:
Unknown directive: =metadata
- Around line 929:
Unknown directive: =partials