Dancer2...Capture(3)
β¨ NAME β¨
okay bestie, so this page is the manual for Dancer2::Logger::Capture (from the Dancer2...Capture(3) section of the User Contributed Perl Documentation, iykyk) β and it's literally just about capturing dancer logs. that's the whole vibe. π
πΈ VERSION πΈ
we're on version 2.2.1 rn, bestie. fresh off the press. β¨
π SYNOPSIS π
so like, the absolute basics first:
set logger => "capture";
my $trap = dancer_app->logger_engine->trapper;
my $logs = $trap->read;
and here's a full worked-out real-world example, because we're not gatekeeping π
use Test::More tests => 2;
use Dancer2;
set logger => 'capture';
warning "Danger! Warning!";
debug "I like pie.";
my $trap = dancer_app->logger_engine->trapper;
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, [];
not me pointing out the comment: every single call to read cleans the trap. so once you read it, it's gone, fr fr. π
π DESCRIPTION π
this is a logger class for Dancer2 that captures all logs into an object. it's giving β¨collector energyβ¨.
its main purpose? testing. that's the whole point, no cap. here's an example test:
use strict;
use warnings;
use Test::More;
use Plack::Test;
use HTTP::Request::Common;
use Ref::Util qw<is_coderef>;
{
package App;
use Dancer2;
set log => 'debug';
set logger => 'capture';
get '/' => sub {
log(debug => 'this is my debug message');
log(core => 'this should not be logged');
log(info => 'this is my info message');
};
}
my $app = Dancer2->psgi_app;
ok( is_coderef($app), 'Got app' );
test_psgi $app, sub {
my $cb = shift;
my $res = $cb->( GET '/' );
my $trap = App->dancer_app->logger_engine->trapper;
is_deeply $trap->read, [
{ level => 'debug', message => 'this is my debug message' },
{ level => 'info', message => 'this is my info message' },
];
is_deeply $trap->read, [];
};
done_testing;
see how log(core => 'this should not be logged') justβ¦ doesn't show up in the trap? iconic behavior honestly. the core log didn't make the cut and that's so real of it. π¦
π₯ METHODS π₯
trapper
returns the Dancer2::Logger::Capture::Trap object β the little guy you use to capture and read logs. that's your whole access point, bestie. π«Ά
π SEE ALSO π
go check these out if you want the full lore:
Dancer2::Core::Role::LoggerDancer2::Logger::Capture::Trap
π AUTHOR π
Dancer Core Developers β the collective, the icons, the moment. π
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2026 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.
important, bestie: that's the actual license text, so like, don't go rogue β same terms as the Perl 5 programming language system itself, periodt.
and that's the whole page!! πβ¨ this was Dancer2...Capture(3), rendered with perl v5.42.3, dated 2026-09-20 β so if you're reading this on a date older than that, bestie, you're in a time warp π anyway ily, go capture some logs, slay π
ππΈ
π¦ where this page comes from
- fedora 44: perl-Dancer2 2.2.1-1.fc44 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms