Rex::Logger(3pm)

πŸ’– Rex::Logger β€” the logging module, bestie edition πŸ’–

okay so this is Rex::Logger, which lives in the Rex::Logger(3pm) part of the User Contributed Perl Documentation, and it's literally the logging module. That's the whole gig. And the best part? You can define your own custom logformats. Obsessed. πŸŽ€


✨ DESCRIPTION ✨

So like. This module is the logging module. That's it, that's the vibe. The little extra spice is that you get to define custom logformats, so your logs can look however you want them to look. main character log lines only πŸ’…


🌸 SYNOPSIS 🌸

Here's how the format thing works, fr fr:

$Rex::Logger::format = '[%D] %s';
# will output something like
# [2012-04-12 18:35:12] Installing package vim

$Rex::Logger::format = '%h - %D - %s';
# will output something like
# srv001 - 2012-04-12 18:35:12 - Installing package vim

see how you just stack the little % codes together and the output shapes itself around them? iconic behaviour honestly ✨


πŸ¦‹ VARIABLES πŸ¦‹

πŸ’œ $debug

Set this bad boy to 1 and debug logging gets switched on. That's it!

$Rex::Logger::debug = 1;

🌈 $silent

Set this one to 1 and nothing will be logged. Not a single line. Silence. The logs simply ✨do not exist✨.

$Rex::Logger::silent = 1;
lowkey a dangerous amount of power but go off 🫢

πŸ‘‘ $format

This is the one where you get to cook. You define your logging format using these parameters:

  • %D β€” appends the current date, formatted as yyyy-mm-dd HH:mm:ss
  • %h β€” the target host
  • %p β€” the pid of the running process
  • %l β€” the loglevel (INFO or DEBUG)
  • %s β€” the logstring

Default is: [%D] %l - %s

Mix and match those however you like and your logs will serve exactly the look you're going for πŸ’…


aaaand that's the whole page, bestie! no cap, no missing flags, nothing skipped, we ate πŸ“

this was Rex::Logger(3pm) from the User Contributed Perl Documentation, and the page footer says perl v5.40.1, dated 2025-10-03. slay, go forth and log 🌟

πŸ“¦ where this page comes from