NAME
Acme::Ghost::Log - Simple logger
SYNOPSIS
use Acme::Ghost::Log;
my $log = Acme::Ghost::Log->new();
$log->error("My test error message to syslog")
# Using file
my $log = Acme::Ghost::Log->new(file => '/tmp/test.log');
$log->error("My test error message to /tmp/test.log")
# Customize minimum log level
my $log = Acme::Ghost::Log->new(level => 'warn');
# Log messages
$log->trace('Doing stuff');
$log->debug('Not sure what is happening here');
$log->info('FYI: it happened again');
$log->warn('This might be a problem');
$log->error('Garden variety error');
$log->fatal('Boom');
DESCRIPTION
Acme::Ghost::Log is a simple logger for Acme::Ghost logging after daemonization
new
my $log = Acme::Ghost::Log->new(
logopt => 'ndelay,pid',
facility => 'user',
level => 'debug',
ident => 'test.pl',
);
With default attributes
use Mojo::Log;
my $log = Acme::Ghost::Log->new( logger => Mojo::Log->new );
$log->error("Test error message");
This is example with external loggers
ATTRIBUTES
This class implements the following attributes
facility
This attribute sets facility for logging
Available standard facilities: auth
, authpriv
, cron
, daemon
, ftp
, kern
, local0
, local1
, local2
, local3
, local4
, local5
, local6
, local7
, lpr
, mail
, news
, syslog
, user
and uucp
Default: user
(Sys::Syslog::LOG_USER)
See also "Facilities" in Sys::Syslog
file
Log file path used by "handle"
handle
Log filehandle, defaults to opening "file" or uses syslog if file not specified
ident
The ident is prepended to every message
Default: script name basename($0)
level
There are six predefined log levels: fatal
, error
, warn
, info
, debug
, and trace
(in descending priority). The syslog supports followed additional log levels: emerg
, alert
, crit'
and notice
(in descending priority). But we recommend not using them to maintain compatibility. Your configured logging level has to at least match the priority of the logging message.
If your configured logging level is warn
, then messages logged with info(), debug(), and trace() will be suppressed; fatal(), error() and warn() will make their way through, because their priority is higher or equal than the configured setting.
Default: debug
See also "Levels" in Sys::Syslog
logger
This attribute perfoms to set predefined logger, eg. Mojo::Log
Default: undef
logopt
This attribute contains zero or more of the options detailed in "openlog" in Sys::Syslog
Default: 'ndelay,pid'
METHODS
This class implements the following methods
alert
$log->alert('Action must be taken immediately');
$log->alert('Real', 'problem');
Log alert
message
crit
$log->crit('Its over...');
$log->crit('Bye', 'bye');
Log crit
message (See "fatal" method)
debug
$log->debug('You screwed up, but that is ok');
$log->debug('All', 'cool');
Log debug
message
emerg
$log->emerg('System is unusable');
$log->emerg('To', 'die');
Log emerg
message
error
$log->error('You really screwed up this time');
$log->error('Wow', 'seriously');
Log error
message
fatal
$log->fatal('Its over...');
$log->fatal('Bye', 'bye');
Log fatal
message
info
$log->info('You are bad, but you prolly know already');
$log->info('Ok', 'then');
Log info
message
level
my $level = $log->level;
$log = $log->level('debug');
Active log level, defaults to debug. Available log levels are trace
, debug
, info
, notice
, warn
, error
, fatal
(crit
), alert
and emerg
, in that order
logger
my $logger = $log->logger;
This method returns the logger object or undef if not exists
notice
$log->notice('Normal, but significant, condition...');
$log->notice('Ok', 'then');
Log notice
message
provider
print $log->provider;
Returns provider name (external
, handle
, file
or syslog
)
trace
$log->trace('Whatever');
$log->trace('Who', 'cares');
Log trace
message
warn
$log->warn('Dont do that Dave...');
$log->warn('No', 'really');
Log warn
message
HISTORY
See Changes
file
TO DO
See TODO
file
SEE ALSO
AUTHOR
Serż Minus (Sergey Lepenkov) https://www.serzik.com <abalama@cpan.org>
COPYRIGHT
Copyright (C) 1998-2023 D&D Corporation. All Rights Reserved
LICENSE
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See LICENSE
file and https://dev.perl.org/licenses/