Plack::...g::Timed(3)

πŸ’– NAME πŸ’–

Plack::Middleware::AccessLog::Timed β€” logs ur requests with time AND accurate body size, bestie πŸ’…

Like, it's the glow-up version of an access log. It tells u how long stuff took and how big the body actually was. Iconic behavior, fr fr.


✨ SYNOPSIS ✨

# in app.psgi
use Plack::Builder;

builder {
    enable "Plack::Middleware::AccessLog::Timed",
        format => "%v %h %l %u %t \"%r\" %>s %b %D";
    $app;
};

okay so u just drop that in ur app.psgi and enable it in the builder, and look at that format string β€” %b and %D are the moment, the main characters 🫢


🌸 DESCRIPTION 🌸

So Plack::Middleware::AccessLog::Timed is literally a subclass of Plack::Middleware::AccessLog, no cap. Except it does a little extra: it uses a wrapped body handle to get the actual response body size for %b β€” even when the body isn't a chunk of array or a real filehandle, which is lowkey so annoying otherwise β€” plus the time taken to serve the request: %T or %D. ⏱️

It wraps the response body output stream specifically to capture the time taken for the PSGI server to read the whole response body. Like, the whole thing. Every last byte. She's thorough. πŸ’β™€οΈ

⚠️ now the tradeoff, and it's a real one: if this middleware is in use, it will prevent some server-side optimizations like sendfile(2) from working. Also middleware like Plack::Middleware::ContentLength can't guess the body size out of the file handle anymore. So yeah. That's the price of knowing things. 😭

BUT listen β€” if all u want is to capture the time taken in ur PSGI application, and u do NOT want the whole wrapped-body situation described above, then consider instead applying Plack::Middleware::Runtime and using Plack::Middleware::AccessLog to log the "X-Runtime" header. That's the lighter, no-drama path. πŸŽ€


πŸ¦‹ CONFIGURATION πŸ¦‹

Same as Plack::Middleware::AccessLog.

That's it. That's the section. She inherits the whole vibe, periodt. πŸ’œ


πŸ‘‘ AUTHOR πŸ‘‘

Tatsuhiko Miyagawa

(an absolute legend, respectfully 🫑)


🌈 SEE ALSO 🌈

  • Plack::Middleware::AccessLog
  • Plack::Middleware::Runtime

ok bestie that's the whole page, u ate it, go log some requests with timestamps and accurate body sizes πŸ’–βœ¨

this has been Plack::...g::Timed(3) from the User Contributed Perl Documentation crew, running on perl v5.42.3, dated 2026-10-18 β€” mwah, bye πŸŽ€πŸ’…

πŸ“¦ where this page comes from