Courie...r::File(3pm)

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

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

okay bestie, so this is a page from the User Contributed Perl Documentation for Courier::Filter::Logger::File β€” the Perl 3pm manual, if you're keeping track πŸ“šβœ¨. Buckle up, it's lowkey iconic.


🌸 NAME 🌸

Courier::Filter::Logger::File β€” the file logger for the Courier::Filter framework. that's it, that's the whole vibe πŸŽ€


✨ SYNOPSIS ✨

use Courier::Filter::Logger::File;

my $logger = Courier::Filter::Logger::File->new(
    file_name => $file_name
);

# 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,
    ...
);

like, copy-paste it, bestie, it's giving plug and play πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

this class is a file logger class, and it's here to hang out with Courier::Filter and all its filter modules 🫢. it inherits from Courier::Filter::Logger::IOHandle β€” so it's literally the child of an icon, no cap πŸ‘‘

πŸŽ€ Constructor πŸŽ€

here's the constructor, bestie:

  • new(%options) β€” returns Courier::Filter::Logger::File; throws Courier::Error.

it creates a brand-new logger that logs messages as lines to a file. it opens the file for writing, and creates it if it doesn't exist yet (yes, it does that ✨).

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

  • file_name β€” Required. it's the name of the file where the log messages get written. no file name, no vibe, fr fr.
  • timestamp β€” a boolean that controls whether every log message line gets prefixed with a timestamp (in local time, in ISO format). defaults to false. so if you want timestamps, you gotta say so 😌

πŸ’œ Instance methods πŸ’œ

these instance methods are provided, inherited from Courier::Filter::Logger::IOHandle:

  • log_error($text) β€” throws Perl exceptions. logs the error message you hand it as $text (a string, and yes it may contain newlines, live your truth). it prefixes each line with a timestamp β€” but only if the "timestamp" option was set through the constructor. otherwise, no timestamps, sorry bestie πŸ•
  • log_rejected_message($message, $reason) β€” throws Perl exceptions. logs the Courier::Message given as $message as having been rejected due to $reason (a string which may contain newlines). dramatic? a little. accurate? yes. πŸ’€

🌈 SEE ALSO 🌈

go check out these icons too:

  • Courier::Filter::Logger::IOHandle
  • Courier::Filter::Logger
  • Courier::Filter::Overview
and bestie, for AVAILABILITY, SUPPORT, and LICENSE info, you gotta look at Courier::Filter::Overview. that's where the whole lore lives πŸ“–βœ¨

πŸ‘‘ AUTHOR πŸ‘‘

Julian Mehnle <julian@mehnle.net> β€” we stan a legend 🫢


okay that's the whole page, bestie, you ate that πŸ’…βœ¨. this was Courier::Filter::File from perl v5.34.0, dated 2022-10-21 β€” the User Contributed Perl Documentation, periodt. now go log something iconic πŸŽ€πŸ¦‹πŸ’–

πŸ“¦ where this page comes from