Courie...:Logger(3pm)
π Courier::Filter::Logger β the vibe π
okay bestie, so you found the manpage for Courier::Filter::Logger, and this one is from the Perl world, running as a 3pm page (that's just how Perl module docs roll). She's the abstract base class for loggers used by the Courier::Filter framework. Abstract means you don't text her directly β you text her kids. Let's get into it. π¦
β¨ NAME β¨
Courier::Filter::Logger β the abstract base class for loggers used by the Courier::Filter framework. lowkey the momager of the whole logger family. π
πΈ SYNOPSIS πΈ
π Courier::Filter logging
use Courier::Filter::Logger::My; # Need to use a non-abstract sub-class.
my $logger = Courier::Filter::Logger::My->new(%options);
# 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,
...
);
Not me pointing out you have to use a non-abstract sub-class β the base class itself literally cannot be instantiated, so Courier::Filter::Logger::My or whoever is doing the actual work. π You can hand your logger to one individual filter module (logger => $logger in Courier::Filter::Module::My->new(...)), or make it the global Courier::Filter logger object (logger => $logger in Courier::Filter->new(...)). Either way, same $logger. slay.
π§ Deriving new logger classes
package Courier::Filter::Logger::My;
use base qw(Courier::Filter::Logger);
That's it, that's the whole inheritance ritual. use base and you're good. β¨
π DESCRIPTION π
So here's the tea: sub-classes of Courier::Filter::Logger get used by the Courier::Filter mail filtering framework and its filter modules, and their whole job is logging errors and message rejections to arbitrary targets β think file handles, databases, wherever. it's giving "flexible logging destination" energy. π
super important bestie: when you override a method in a derived class, do not forget to call the inherited method from your overridden one. no cap. do not skip this.
π Constructor
The following constructor is provided, and yeah, you can override it:
new(%options): returnsCourier::Filter::Loggerβ creates a new logger using the%optionsyou pass as a list of key/value pairs. It initializes said logger by doing the setup stuff: creating/opening I/O handles, connecting to databases, etc. π«Ά
Worth knowing: Courier::Filter::Logger::new() creates a hash-ref as an object of the invoked class and stores the %options in it, but does nothing else. that's the whole base-class personality.
πΈ Destructor
The following destructor is provided, and yep, overridable:
destroyβ uninitializes the logger: closing I/O handles, disconnecting from databases, etc. π§Ή
Courier::Filter::Logger::destroy() does nothing. Sub-classes may override this method and define clean-up behavior. so if you need cleanup, that's on you, bestie.
β Instance methods
The following instance methods are provided, and β you guessed it β may be overridden:
log_error($text)β logs the error message given as$text, a string which may contain newlines. π
Courier::Filter::Logger::log_error() does nothing and should be overridden. like, please override it. it's doing nothing on purpose.
log_rejected_message($message, $reason)β logs theCourier::Messagegiven as$messageas having been rejected due to$reason(a string which may contain newlines). π
Courier::Filter::Logger::log_rejected_message() does nothing and should be overridden. same deal. base class is just a silhouette, the sub-class is the main character.
π¦ SEE ALSO π¦
Courier::FilterCourier::Filter::Module
For a list of prepared loggers that come with Courier::Filter, see "Bundled Courier::Filter loggers" in Courier::Filter::Overview.
For AVAILABILITY, SUPPORT, and LICENSE information, see Courier::Filter::Overview.
π AUTHOR π
Julian Mehnle <julian@mehnle.net> β thank you for your service, king. π
aaaand that's the whole page, bestie! this one shipped with perl v5.34.0 and is dated 2022-10-21. go forth and log responsibly. πβ¨
π¦ where this page comes from
- debian bookworm: courier-filter-perl 0.200+ds-6 Β· Artistic-1.0-Perl OR GPL-2.0-or-later
- debian trixie: courier-filter-perl 0.200+ds-6 Β· Artistic-1.0-Perl OR GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms