NAME
Log::Minimal - Minimal but customizable logger.
SYNOPSIS
use Log::Minimal;
critf("%s","foo"); # 2010-10-20T00:25:17 [CRITICAL] foo at example.pl line 12
warnf("%d %s", 1, "foo");
infof("foo");
debugf("foo"); print if $ENV{LM_DEBUG} is true
# with full stack trace
critff("%s","foo");
# 2010-10-20T00:25:17 [CRITICAL] foo at lib/Example.pm line 10, example.pl line 12
warnff("%d %s", 1, "foo");
infoff("foo");
debugff("foo"); print if $ENV{LM_DEBUG} is true
DESCRIPTION
Log::Minimal is Minimal but customizable log module.
EXPORT FUNCTIONS
- critf(($message:Str|$format:Str,@list:Array));
-
critf("could't connect to example.com"); critf("Connection timeout timeout:%d, host:%s", 2, "example.com");
Display CRITICAL messages. When two or more arguments are passed to the function, the first argument is treated as a format of printf.
- warnf(($message:Str|$format:Str,@list:Array));
-
Display WARN messages.
- infof(($message:Str|$format:Str,@list:Array));
-
Display INFO messages.
- debugf(($message:Str|$format:Str,@list:Array));
-
Display DEBUG messages, if $ENV{LM_DEBUG} is true.
- critff(($message:Str|$format:Str,@list:Array));
-
critff("could't connect to example.com"); critff("Connection timeout timeout:%d, host:%s", 2, "example.com");
Display CRITICAL messages with stack trace.
- warnff(($message:Str|$format:Str,@list:Array));
-
Display WARN messages with stack trace.
- infoff(($message:Str|$format:Str,@list:Array));
-
Display INFO messages with stack trace.
- debugff(($message:Str|$format:Str,@list:Array));
-
Display DEBUG messages with stack trace, if $ENV{LM_DEBUG} is true.
CUSTOMIZE
To customize the method of outputting the log, set $Log::Minimal::PRINT.
# with PSGI Application. output log with request uri.
my $app = sub {
my $env = shift;
local $Log::Minimal::PRINT = sub {
my ( $time, $type, $message, $trace) = @_;
$env->{psgi.errors}->print(
"$time [$env->{SCRIPT_NAME}] [$type] $message at $trace\n");
};
run_app(...);
}
default
sub {
my ( $time, $type, $message, $trace) = @_;
warn "$time [$type] $message at $trace\n";
}
AUTHOR
Masahiro Nagano <kazeburo {at} gmail.com>
SEE ALSO
LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.