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


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