Fault::Delegate::File - File logger delegate.


Fault documentation  | view source Contained in the Fault distribution.

Index


NAME

Top

 Fault::Delegate::File - File logger delegate.

SYNOPSIS

Top

 use Fault::Delegate::File;
 $self = Fault::Delegate::File->new ($filepath);
 $okay = $self->log                 ($msg);

Inheritance

Top

 UNIVERSAL
   Fault::Delegate
     Fault::Delegate::File

Description

Top

This is a delegate that writes log messages to a specified file. The file must be writeable to the calling program.

Fault::Delegate::File satisfies the minimum requirements of the Fault::Delegate logger delegate protocol.

Examples

Top

 use Fault::Delegate::File;
 use Fault::Logger;
 use Fault::Msg;

 my $msg       = Fault::Msg                 ("Arf!");
 my $baz       = Fault::Delegate::File->new ("/tmp/mylogfile");
 my $waslogged = $baz->log                  ($msg);

                 Fault::Logger->new         ($baz);
 my $waslogged = Fault::Logger->log         ("Bow! Wow!");

 [See Fault::Logger for a detailed example.]

Instance Variables

Top

 filepath	Full path to the log file.
 init           True if the log file has been successfully opened at
                least once.
 fd             Transient storage for filehandle.

Class Methods

Top

$delegate = Fault::Delegate::File->new ($filepath)

Create a logger delegate object that writes log messages to the designated file.

A warning is issued if there is no $filepath argument and in that case undef is returned to indicate that a delegate could not be created.

If the initialization message cannot be written a warning is issued and undef is returned.

Logger Protocol Instance Methods

Top

$okay = $self->log ($msg)

Prints a time-stamped message to the associated log file using information taken from Fault::Msg object $msg:

       $date $time UTC> $processname: $type($priority): $msg\n

for example:

       20021207 223010 UTC> MyProcess: NOTE(notice): Nothing happened again.\n

and return true if we succeeded in doing so.

Private Class Methods

Top

None.

Private Instance Methods

Top

$bool = $self->_write ($msg)
$bool = $self->_connect
$bool = $self->_disconnect

Impliments the above overrides to the internal family protocol utilized by the Fault:Delegate log and test methods.

Errors and Warnings

Top

Local warning messages are issued if the db file cannot be opened or has any problems whatever.

KNOWN BUGS

Top

 See TODO.

SEE ALSO

Top

Fault::Logger, Fault::Delegate, Fault::Msg, Fault::ErrorHandler

AUTHOR

Top

Dale Amon <amon@vnl.com>


Fault documentation  | view source Contained in the Fault distribution.