NAME
Su::Log - A Simple Logger that has the feature of recognizing log level and narrowing down the logging target class.
SYNOPSYS
Su::Log->on('Target::Module::Name');
Su::Log->set_level("trace");
my $log = Su::Log->new;
$log->info("info message");
Su::Log->on(__PACKAGE__);
Su::Log::info("info message");
DESCRIPTION
Su::Log is a simple Logger module. Su::Log has the following features.
- Narrow down the output by log level.
- Narrow down the logging target class.
- Narrow down the output by customized log kind.
- Customize the log handler function.
FUNCTIONS
- on()
-
Add the passed module name to the list of the logging tareget. If the parameter is not passed, then set the whole class as logging target.
- off()
-
Remove the passed module name from the list of the logging tareget.
- clear_all_flag()
-
Clear
$all_on
and$all_off
flags. - tag_on()
-
Add the passed tag to the target tags list.
- tag_off()
-
Remove the passed tag from the target tags list.
- new()
-
Constructor.
my $log = new Su::Log->new; my $log = new Su::Log->new($self); my $log = new Su::Log->new('PKG::TargetClass');
Instantiate the Logger class. The passed instance or the string of the module name is registered as a logging target class. If the parameter is omitted, then the caller is registered automatically.
- is_target()
-
Determine whether the module is a logging target or not.
- set_level()
-
Su::Log->set_level("trace");
Set the log level. This setting effects as the package scope variable.
- is_large_level()
-
Return whether the passed log level is larger than the current log level or not.
- trace()
-
Log the passed message as trace level.
- info()
-
Log the passed message as info level.
- warn()
-
Log the passed message as warn level.
- error()
-
Log the passed message as error level.
- crit()
-
Log the passed message as crit level.
- log()
-
Log the message with the passed tag, if the passed tag is active.
my $log = Su::Log->new($self); $log->log("some_tag","some message");
- log_handler()
-
Specify the passed method as the log handler of Su::Log.
$log->log_handler(\&hndl); $log->info("info message"); sub hndl{ print(join 'custom log handler:', @_); }