NAME
Log::Log4Cli -- Lightweight logger for command line tools
VERSION
Version 0.18
SYNOPSIS
use Log::Log4Cli;
$Log::Log4Cli::COLORS->{DEBUG} = 'green'; # redefine color (Term::ANSIColor notation)
$Log::Log4Cli::LEVEL = 4; # set loglevel
$Log::Log4Cli::POSITIONS = 1; # force file:line marks (also enables if loglevel > 4)
log_fd(\*STDOUT); # print to STDOUT (STDERR by default)
log_error { "blah-blah, it's an error" };
$Log::Log4Cli::COLOR = 0; # now colors disabled
my $guts = { some => "value" };
log_trace { # block executed when appropriate level enabled only
require Data::Dumper;
return "Guts:\n" . Data::Dumper->Dump([$guts]);
};
die_info 'All done', 0;
DESCRIPTION
Lightweight, but sufficient and user friendly logging for command line tools with minimal impact on performance, no configuration and no non-core dependencies.
EXPORT
All subroutines described below are exported by default.
SUBROUTINES
die_fatal, die_alert, die_notice, die_info
die_fatal "Something terrible happened", 8;
Log message and exit with provided code. All arguments are optional. If second arg (exit code) omitted die_fatal, die_alert and die_info will exit with 127, 0 and 0 respectively. die_notice
is deprecated and will be removed in future releases.
log_fatal, log_error, log_alert, log_notice, log_warn, log_info, log_debug, log_trace
log_error { "Something went wrong!" };
Execute passed code block and write it's return value if loglevel permit so. Set $Log::Log4Cli::COLOR
to false value to disable colors. log_notice
is deprecated and will be removed in future releases.
log_fd
Get/set file descriptor for log messages. STDERR
is used by default.
LOG LEVELS
Only builtin loglevels supported:
FATAL -1 'bold red',
ERROR 0 'red',
ALERT 0 'bold yellow',
WARN 1 'yellow',
INFO 2 'cyan',
DEBUG 3 'blue',
TRACE 4 'magenta'
Colors may be changed, see "SYNOPSIS". Default loglevel is ERROR
(0).
SEE ALSO
LICENSE AND COPYRIGHT
Copyright 2016,2017 Michael Samoglyadov.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.