| Courier-Filter documentation | Contained in the Courier-Filter distribution. |
Courier::Filter::Logger - Abstract base class for loggers used by the Courier::Filter framework
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,
...
);
package Courier::Filter::Logger::My;
use base qw(Courier::Filter::Logger);
Sub-classes of Courier::Filter::Logger are used by the Courier::Filter mail filtering framework and its filter modules for the logging of errors and message rejections to arbitrary targets, like file handles or databases.
When overriding a method in a derived class, do not forget calling the inherited method from your overridden method.
The following constructor is provided and may be overridden:
Creates a new logger using the %options given as a list of key/value pairs. Initializes the logger, by creating/opening I/O handles, connecting to databases, etc..
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.
The following destructor is provided and may be overridden:
Uninitializes the logger, by 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.
The following instance methods are provided and may be overridden:
Logs the error message given as $text (a string which may contain newlines).
Courier::Filter::Logger::log_error() does nothing and should be overridden.
Logs the Courier::Message given as $message as having been rejected due to $reason (a string which may contain newlines).
Courier::Filter::Logger::log_rejected_message() does nothing and should be
overridden.
Courier::Filter, Courier::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.
Julian Mehnle <julian@mehnle.net>
| Courier-Filter documentation | Contained in the Courier-Filter distribution. |
# # Courier::Filter::Logger abstract base class # # (C) 2003-2008 Julian Mehnle <julian@mehnle.net> # $Id: Logger.pm 210 2008-03-21 19:30:31Z julian $ # ###############################################################################
package Courier::Filter::Logger; use warnings; use strict; use Error ':try'; use Courier::Error; use constant TRUE => (0 == 0); use constant FALSE => not TRUE;
# Implementation: ###############################################################################
sub new { my ($class, %options) = @_; $class ne __PACKAGE__ or throw Courier::Error('Unable to instantiate abstract ' . __PACKAGE__ . ' class'); my $self = { %options }; return bless($self, $class); }
sub destroy { my ($self) = @_; return; }
sub log_error { my ($self, $text) = @_; return; }
sub log_rejected_message { my ($self, $message, $reason) = @_; return; }
BEGIN { no warnings 'once'; *DESTROY = \&destroy; }
TRUE;