Dancer...Capture(3pm)

πŸ’– Dancer::Logger::Capture β€” capturing dancer logs, bestie πŸ’–

okay so this is one of those pages from the User Contributed Perl Documentation collection, and it's Dancer::Logger::Capture, version 1.3522 ✨ it's a tiny little thing and it's lowkey iconic, so let's get into it πŸ’…


✨ NAME ✨

Dancer::Logger::Capture β€” captures dancer logs, that's the whole job πŸŽ€


🌸 VERSION 🌸

version 1.3522 πŸ’œ


πŸ¦‹ SYNOPSIS πŸ¦‹

set logger => "capture";

my $trap = Dancer::Logger::Capture->trap;
my $logs = $trap->read;

like. that's it. three lines. main character energy fr fr πŸ‘‘


πŸ’« DESCRIPTION πŸ’«

okay so bestie, this is a logger class for Dancer, and what it does is it captures all the logs into an object πŸ“¦βœ¨

its primary purpose? testing. periodt. that's what it's for πŸ’…

πŸŽ€ Methods πŸŽ€

trap

returns the Dancer::Logger::Capture::Trap object that you use to capture and read logs πŸͺ€πŸ’– it's giving "i set a trap and the logs walked right into it" and honestly? obsessed.


🌈 EXAMPLE 🌈

here's the whole vibe, verbatim, no notes:

use Test::More import => ['!pass'], tests => 2;
use Dancer;

set logger => 'capture';

warning "Danger!  Warning!";
debug   "I like pie.";

my $trap = Dancer::Logger::Capture->trap;
is_deeply $trap->read, [
    { level => "warning", message => "Danger!  Warning!" },
    { level => "debug",   message => "I like pie.", }
];

# each call to read cleans the trap
is_deeply $trap->read, [];

okay important detail because everyone misses it: each call to read cleans the trap 🧹 so the second read gives you an empty array. she empties herself out every single time. iconic behaviour honestly 😌✨


πŸ”₯ SEE ALSO πŸ”₯

  • Dancer::Logger
  • Dancer::Logger::Capture::Trap

go read those too, bestie, iykyk 🫢


πŸ‘‘ AUTHOR πŸ‘‘

the Dancer Core Developers πŸ’œ


this software is copyright (c) 2010 by Alexis Sukrieh 🌸

this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself πŸ’– (yes that means free free, go wild but read the license fr)


okay that's the whole page!! πŸŽ€ and a cute little sign-off for you: this was perl v5.40.1, dated 2026-05-05, and that's the Dancer...Capture(3pm) footer moment πŸ’…βœ¨ love u, go write some tests πŸ’œπŸ¦‹

πŸ“¦ where this page comes from