Plack:...Errors(3pm)
π NAME π
Plack::Middleware::LogErrors β bestie, this middleware maps psgi.errors to psgix.logger or literally any other logger you want. It's the glow-up your error stream has been waiting for. π¦
β¨ VERSION β¨
version 0.003 β small number, big slay. π
πΈ SYNOPSIS πΈ
Okay so scenario one: you already have a logger configured (we're using Log::Dispatch as the example here, keep up bestie):
use Log::Dispatch;
my $logger = Log::Dispatch->new;
$logger->add( Log::Dispatch::File->new(...) );
builder {
enable 'LogDispatch', logger => $logger;
enable 'LogErrors';
$app;
}
Scenario two: you're handing it a logger explicitly, main character style:
builder {
enable 'LogErrors', logger => sub {
my $args = shift;
$logger->log(%$args);
};
$app;
}
Periodt. Two vibes, one middleware. π
π DESCRIPTION π
So here's the tea β: psgi.errors defaults to STDERR in most backends. And likeβ¦ where does that go? Somewhere deeply unhelpful, like the server console. Not the vibe. Not even a little bit.
This middleware just remaps the psgi.errors stream over to the psgix.logger stream, or to an explicit logger that you provide. Simple as. π§
And it is especially handy when you stack it with other middlewares, like:
Plack::Middleware::LogWarnβ which diverts Perl warnings topsgi.errorsPlack::Middleware::HTTPExceptionsβ which diverts uncaught exceptions topsgi.errorsPlack::Middleware::AccessLogβ which defaults topsgi.errorswhen you don't pass it a logger. And fun fact: that one gets automatically applied viaplackup! So if you gave no--access-logoption indicating a filename,psgi.errorsis what gets used. iykyk π
π« CONFIGURATION π«
logger
loggerβ a code reference for logging messages, that conforms to thepsgix.loggerspecification. If you don't provide one,psgix.loggergets used instead β or, if there's no such logger configured, the application will generate an error at runtime. π«
So likeβ¦ give it a logger. Or have one. One of the two. Bestie, please. π
π₯ SEE ALSO π₯
- PSGI::Extensions β the definition of
psgix.logger - "The Error Stream" in PSGI β the definition of
psgi.errors - Plack::Middleware::LogWarn β maps warnings to
psgi.errors - Plack::Middleware::HTTPExceptions β maps exceptions to
psgi.errors - Plack::Middleware::LogDispatch β use a
Log::Dispatchlogger forpsgix.logger - Plack::Middleware::Log4perl β use a
Log::Log4perllogger forpsgix.logger - Plack::Middleware::SimpleLogger β essentially the opposite of this module! π
π«Ά SUPPORT π«Ά
Bugs may be submitted through the RT bug tracker at <https://rt.cpan.org/Public/Dist/Display.html?Name=Plack-Middleware-LogErrors>, or you can email bug-Plack-Middleware-LogErrors@rt.cpan.org. π
There's also a mailing list available for users of this distribution, over at <https://groups.google.com/forum/#!forum/psgi-plack>.
And there's an irc channel available for users of this distribution too β it's #plack on irc.perl.org (<irc://irc.perl.org/#plack>).
The author is also usually active on irc, as 'ether' at irc.perl.org. Say hi, she's lovely. π
π AUTHOR π
Karen Etheridge <ether@cpan.org>
π COPYRIGHT AND LICENCE π
This software is copyright (c) 2013 by Karen Etheridge.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Slay, honestly. π
and that's the whole page bestie β perl v5.28.1, dated 2019-02-20, from the User Contributed Perl Documentation collection π β¨
π¦ where this page comes from
- debian bookworm: libplack-middleware-logerrors-perl 0.003-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libplack-middleware-logerrors-perl 0.003-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libplack-middleware-logerrors-perl 0.003-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libplack-middleware-logerrors-perl 0.003-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms