Courie...OHandle(3pm)

πŸ“¦
version 0.200 Β· 2 versions
, in debian bookworm, debian trixie

πŸ’– Courier::Filter::Logger::IOHandle πŸ’–

okay bestie so this is the User Contributed Perl Documentation page for Courier::Filter::Logger::IOHandle (it's section 3pm, the Perl module girlies know ✨). It's genuinely one of the easiest little modules to love so let's get into it 🫢


🌸 NAME 🌸

Courier::Filter::Logger::IOHandle β€” the I/O handle logger for the Courier::Filter framework. that's it. that's the whole job. she logs to a handle. iconic behavior πŸ’…


✨ SYNOPSIS ✨

use Courier::Filter::Logger::IOHandle;

my $logger = Courier::Filter::Logger::IOHandle->new(
    handle => $handle
);

# For use in an individual filter module:
my $module = Courier::Filter::Module::My->new(
    ...
    logger => $logger,
    ...
);

# For use as a global Courier::Filter logger object:
my $filter = Courier::Filter->new(
    ...
    logger => $logger,
    ...
);

see how chill that is?? make the logger, hand it a handle, then either slot it into one filter module or make it the global logger for the whole Courier::Filter object. main character energy for a logger fr fr 😌


πŸ¦‹ DESCRIPTION πŸ¦‹

So this class is an I/O handle logger class, and you use it with Courier::Filter and with its filter modules. That's the vibe. She writes your log messages out to a handle, done πŸ’–


πŸŽ€ Constructor πŸŽ€

Here's the one constructor she comes with, bestie:

new(%options): returns Courier::Filter::Logger::IOHandle

Makes you a brand new logger that logs messages as lines to an I/O handle. no cap 🧚

%options is a list of key/value pairs, and you can pass any of these:

  • handle β€” Required. This is the I/O handle, or the IO::Handle object, that log messages get written to. You gotta give her one, she will not spawn her own, periodt πŸ™ˆ
  • timestamp β€” A boolean value. It controls whether every single log message line gets prefixed with a timestamp β€” and that timestamp is in local time, in ISO format. Defaults to false, so if you want stamps you gotta ask for them πŸ’…

🌈 Instance methods 🌈

Two methods, both of them little divas that throw Perl exceptions. Noted. Respectfully. 😭

log_error($text): throws Perl exceptions

Logs the error message you hand it as $text. And heads up: $text is a string that may contain newlines β€” she handles that, she just checks each line. If you set the "timestamp" option back in the constructor, every line gets prefixed with a timestamp. ✨

log_rejected_message($message, $reason): throws Perl exceptions

Logs the Courier::Message given as $message as having been rejected, and the reason why is $reason β€” which, same deal, is a string that may contain newlines. Bye bye message, hello log entry πŸ‘‹


πŸ‘‘ SEE ALSO πŸ‘‘

  • Courier::Filter::Logger
  • Courier::Filter::Overview

And for AVAILABILITY, SUPPORT, and LICENSE info, bestie, you go look at Courier::Filter::Overview. all the fine print lives there 🫢


πŸ’œ AUTHOR πŸ’œ

Julian Mehnle <julian@mehnle.net> β€” thank you for your service king 🫑


not me getting emotional over a logger module 😭 she's small, she's focused, she writes lines to a handle. we stan.

slay, that's the whole page. This lil' thing shipped as part of perl v5.34.0, dated 2022-10-21. mwah πŸ’–πŸ’…βœ¨

πŸ“¦ where this page comes from