Plack:...Errors(3pm)

πŸ“¦
version 0.003 Β· 2 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble

πŸ’– 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 to psgi.errors
  • Plack::Middleware::HTTPExceptions β€” which diverts uncaught exceptions to psgi.errors
  • Plack::Middleware::AccessLog β€” which defaults to psgi.errors when you don't pass it a logger. And fun fact: that one gets automatically applied via plackup! So if you gave no --access-log option indicating a filename, psgi.errors is what gets used. iykyk 😌

πŸ’« CONFIGURATION πŸ’«

logger

  • logger β€” a code reference for logging messages, that conforms to the psgix.logger specification. If you don't provide one, psgix.logger gets 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::Dispatch logger for psgix.logger
  • Plack::Middleware::Log4perl β€” use a Log::Log4perl logger for psgix.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>


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