SYNOPSIS
use App::CELL::Log qw( $log );
# set up logging for application FooBar -- need only be done once
$log->init( ident => 'FooBar' );
# do not suppess 'trace' and 'debug' messages
$log->init( debug_mode => 1 );
# do not append filename and line number of caller
$log->init( show_caller => 0 );
# log messages at different log levels
my $level = 'warn' # can be any of the levels provided by Log::Any
$log->$level ( "Foobar log message" );
# the following App::CELL-specific levels are supported as well
$log->ok ( "Info-level message prefixed with 'OK: '");
$log->not_ok ( "Info-level message prefixed with 'NOT_OK: '");
# by default, the caller's filename and line number are appended
# to suppress this for an individual log message:
$log->debug ( "Debug-level message", suppress_caller => 1 );
# Log a status object (happens automatically when object is
# constructed)
$log->status_obj( $status_obj );
# Log a message object
$log->message_obj( $message_obj );
EXPORTS
This module provides the following exports:- $log - App::CELL::Log singleton
PACKAGE VARIABLES
- $ident - the name of our application
- $show_caller - boolean value, determines if caller information is displayed in log messages
- $debug_mode - boolean value, determines if we display debug messages
- $log - App::CELL::Log singleton object
- $log_any_obj - Log::Any singleton object
- @permitted_levels - list of permissible log levels
DESCRIPTION
App::CELL's logs using Log::Any. This "App::CELL::Log" module exists to: (1) provide documentation, (2) store the logging category ($ident), (3) store the Log::Any log object, (4) provide convenience functions for logging 'OK' and 'NOT_OK' statuses.METHODS
debug_mode
If argument provided, set the $debug_mode package variable. If no argument, simply return the current debug-mode setting. Examples:
$log->debug_mode(0); # turn debug mode off $log->debug_mode(1); # turn debug mode on print "Debug mode is on\n" if $log->debug_mode;
ident
Set the $ident package variable and the Log::Any categoryshow_caller
Set the $show_caller package variablepermitted_levels
Access the @permitted_levels package variable.init
Initializes (or reconfigures) the logger. Although in most cases folks will want to call this in order to set "ident", it is not required for logging to work. See App::CELL::Guide for instructions on how to log with App::CELL.Takes PARAMHASH as argument. Recognized parameters:
- "ident" --- (i.e., category) string, e.g. 'FooBar' for the FooBar application, or 'CELLtest' if none given
- "show_caller" --- sets the $show_caller package variable (see above)
- "debug_mode" --- sets the $debug_mode package variable (see above)
Always returns 1.
DESTROY
For some reason, Perl 5.012 seems to want a DESTROY methodAUTOLOAD
Call Log::Any methods after some pre-processingstatus_obj
Take a status object and log it.