Plack::Middleware::Log::Minimal - Log::Minimal middleware to prints to psgi.errors
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
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.
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.
Enable $Log::Minimal::AUTODUMP for serialize object or reference message.
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 name to display log. This middleware encode (utf8 flagged) text log messages automatically. Default is utf8
Masahiro Nagano <kazeburo {at} gmail.com>
Log::Minimal
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Plack::Middleware::Log::Minimal, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Plack::Middleware::Log::Minimal
CPAN shell
perl -MCPAN -e shell install Plack::Middleware::Log::Minimal
For more information on module installation, please visit the detailed CPAN module installation guide.