Assure1::Log Perl library¶
Description¶
Log module to provide a consistent API and format for logging.
You must always "use" this module after threads::shared
Synopsis¶
use threads::shared;
use Assure1::Log;
our $Log = new Assure1::Log({
LogFile => $LogFile,
LogLevel => $LogLevel
AppID => $AppID
});
$Log->Message($Level, $Message);
$Log->Message($Level, [$Message1, $Message2, ...]);
Constructor¶
new¶
Creates a logging instance.
new(\%options)
Options
Config -> (optional) Non-default configuration file
LogFile -> Full path to log file
LogLevel -> Level string {OFF, FATAL, ERROR, WARN, INFO, DEBUG, TRACE}
AppID -> (optional) Unique application ID
Returns
Log instance
Methods¶
ChangeLogLevel¶
Change logging level.
ChangeLogLevel($LogLevel)
Arguments
LogLevel -> Level string {OFF, FATAL, ERROR, WARN, INFO, DEBUG, TRACE}
ChangeLogFile¶
Change log file.
ChangeLogFile($LogFile)
Arguments
LogFile -> Full path to log file
Close¶
Flushes and closes log file. Will reopen file if Message is called after closing.
GetLogLevel¶
Lookup LogLevel name by ID
GetLogLevel($LogLevelID)
Arguments
LogLevelID -> Level number
Returns
0 => 'OFF'
1 => 'FATAL'
2 => 'ERROR'
3 => 'WARN'
4 => 'INFO'
5 => 'DEBUG'
6 => 'TRACE'
GetLogLevelID¶
Lookup LogLevel ID by name
GetLogLevelID($LogLevel)
Arguments
LogLevel -> Level string {OFF, FATAL, ERROR, WARN, INFO, DEBUG, TRACE}
Returns
'OFF' => 0
'FATAL' => 1
'ERROR' => 2
'WARN' => 3
'INFO' => 4
'DEBUG' => 5
'TRACE' => 6
Message¶
Send log message with specific log level. Message can be a scalar or an array reference of multiple log messages.
Message($LogLevel, $Message)
Arguments
LogLevel -> Level string {OFF, FATAL, ERROR, WARN, INFO, DEBUG, TRACE}
Message -> String of a single message or an array reference of multiple string messages
Reopen¶
Force a close and re-open the log file
Reopen($LogFile)
Arguments
LogFile -> Full path to log file