NAME
Plack::Middleware::Log::Minimal - Log::Minimal middleware to prints to psgi.errors
SYNOPSIS
use Log::Minimal;
use Plack::Builder;
builder {
enable "Plack::Middleware::Log::Minimal", autodump => 1;
sub {
my $env = shift;
debugf("debug message");
infof("infomation message");
warnf("warning message");
critf("critical message");
["200",[ 'Content-Type' => 'text/plain' ],["OK"]];
};
};
# print "2010-10-20T00:25:17 [INFO] infomation message at example.psgi" to psgi.errors stream
DESCRIPTION
Plack::Middleware::Log::Minimal is middleware that integrates with Log::Minimal. When Log::Minimal log functions like warnf, infof or debugf were used in PSGI Application, this middleware adds requested URI to messages and prints that to psgi.errors stream.
IF $ENV{PLACK_ENV} is "development", Plack::Middleware::Log::Minimal enable Log::Minimal::COLOR automatically.
CONFIGURATIONS
- loglevel
-
Set the log level to output.
enable 'Log::Level', loglevel => 'INFO';
Support levels are DEBUG,INFO,WARN,CRITICAL and NONE. If NONE is set, no output. Default log level is DEBUG.
- autodump
-
Enable $Log::Minimal::AUTODUMP for serialize object or reference message.
- formatter
-
Log format CODE reference. Default is.
enable 'Log::Minimal', formatter => sub { my ($env, $time, $type, $message, $trace, $raw_message) = @_; sprintf "%s [%s] [%s] %s at %s\n", $time, $type, $env->{REQUEST_URI}, $message, $trace; });
You can filter log messages and add more request information to message in this formatter CODE ref. $message includes Term color characters, If you want raw message text, use $raw_message.
- encoding
-
Encoding name to display log. This middleware encode (utf8 flagged) text log messages automatically. Default is utf8
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.