Dancer2...::Logger(3)
π Dancer2::Core::Role::Logger π
okay bestie, welcome to Dancer2::Core::Role::Logger(3) β yeah it's a role, yeah it's fancy, and yeah we're gonna get through it together. grab a snack. π
β¨ VERSION β¨
version 2.2.1 β she's serving 2.2.1 and that's that. π
πΈ DESCRIPTION πΈ
so any class that consumes this role gets to write log messages. that's the whole vibe. it's giving "plug me into your engine and I'll handle the words." π
but there's a catch, and it's a big one: to actually implement this role, the consumer must implement the log method. no log method, no logging. periodt.
and that log method? it receives as arguments the level and the message. those two. in that order. that's the deal. π«Ά
π ATTRIBUTES π
auto_encoding_charset
charset to use when writing a message. yes it's about encoding. yes it matters. π₯
app_name
name of the application. can be used in the message. cute little flex for your log lines. β¨
log_format
this is a format string (or a preset name) that says what your log format looks like. it's giving "choose your own adventure but for log lines."
the possible values are:
%aβ app name%hβ host emitting the request%tβ date (local timezone, formatted like%d/%b/%Y %H:%M:%S)%Tβ date (local timezone, formatted like%Y-%m-%d %H:%M:%S)%uβ date (UTC timezone, formatted like%d/%b/%Y %H:%M:%S)%Uβ date (UTC timezone, formatted like%Y-%m-%d %H:%M:%S)%Pβ PID%Lβ log level%mβ message%pβ package name that emits the message%fβ file name that emits the message%lβ line from the file%iβ request ID%{$fmt}tβ timer formatted with a valid time format%{header}hβ header value
now here's the part where we stay calm π: a format character that is not in that list above β whether you mistyped it or it's just simply unsupported β is not fatal. it does not blow up your whole day. instead it produces a Carp warning of the form %X not supported. and the field renders as -, leaving the rest of the log line intact. so your line survives. she's resilient. πβ‘οΈπ
log_level
level to use by default. the default default, if you will.
π METHODS π
core
Log messages as core.
debug
Log messages as debug.
info
Log messages as info.
warning
Log messages as warning.
error
Log messages as error.
format_message
Provides a common message formatting. one formatter to rule them all. π
map_chars_to_subs
Returns a hashref which has all the items needed for message formatting. it's the little lookup table that makes the magic happen. iykyk. β
π¦ CONFIGURATION π¦
the logger configuration variable tells Dancer2 which engine to use. that's the whole job. no notes.
you can change it either in your config.yml file:
# logging to console
logger: "console"
the log format can also be configured, please see "log_format" in Dancer2::Core::Role::Logger for details. go read that bit, bestie, it's right up there. π§
π AUTHOR π
Dancer Core Developers
π 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.
and that's the whole page!! mwah π no cap, every option, every format char, every warning β all present and accounted for.
okay so this was Dancer2::Core::Role::Logger, shipped in perl v5.42.3, dated 2026-09-20, and it ate. go forth and log, bestie πβ¨π
π¦ 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