The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

App::Framework::Feature::Logging - Application logging

SYNOPSIS

  # Include logging feature by:
  use App::Framework '+Logging' ;

DESCRIPTION

Logging feature that provides log file handling for applications.

If the user specified -log command line option and specifies a valid log filename, then this module will manage any logging() calls, writing the data into the specified log file.

FIELDS

The following fields should be defined either in the call to 'new()', as part of a 'set()' call, or called by their accessor method (which is the same name as the field):

logfile - Name of log file

Created by the object. When the application starts, if the -log option has been specified, then the filename is copied into this field.

mode - Log file create mode

May be 'truncate' or 'append': 'truncate' clears any previous log file contents; 'append' appends the logging to previous file contents. Default is 'truncate'

to_stdout - flag to echo logging

When set, causes all logging to be echoed to STDOUT

ADDITIONAL COMMAND LINE OPTIONS

This feature adds the following additional command line options to any application:

-log - Specify a log file

If a logfile is specified at the command line, then the file is created and all logging messages get written to that file. Otherwise, log messages are ignored.

CONSTRUCTOR

new([%args])

Create a new Logging.

The %args are specified as they would be in the set method (see "Fields").

CLASS METHODS

init_class([%args])

Initialises the Logging object class variables.

OBJECT METHODS

application_entry()

Called by the application framework at the start of the application.

This method checks for the user specifying any of the options described above (see "ADDITIONAL COMMAND LINE OPTIONS") and handles them if so.

logging($arg1, [$arg2, ....])

Log the argument(s) to the log file iff a log file has been specified.

The list of arguments may be: SCALAR, ARRAY reference, HASH reference, SCALAR reference. SCALAR and SCALAR ref are printed as-is without any extra newlines. ARRAY ref is printed out one entry per line with a newline added. The HASH ref is printed out in the format produced by App::Framework::Base::Object::DumpObj.

echo_logging($arg1, [$arg2, ....])

Same as "logging" but echoes output to STDOUT.

Logging([%args])

Alias to "logging"

DIAGNOSTICS

Setting the debug flag to level 1 prints out (to STDOUT) some debug messages, setting it to level 2 prints out more verbose messages.

AUTHOR

Steve Price <sdprice at cpan.org>

BUGS

None that I know of!