
Log::Info - Wrapper around Log::Log4perl

This tool is now just a wrapper around Log::Log4perl. The author recommends that you use that module instead; this module is maintained purely to provide a migration path thereto.
All documentation for using Log::Info has been excised, except for that which will aid migration.

use Log::Info qw( :log_levels :default_channels Log Logf );
# The Log::Info default channels appear in Log::Log4perl as loggers called
# colon-lowercase-<channelname>, e.g., INFO appears as ':info'.
#
# note, use init, not init_once, since Log::Info has already called init
# if you have used :default_channels to auto-create the default channels
# (or else contrived to call Log() or Logf() already)
Log::Log4perl::init
(+{
'log4perl.rootLogger' => 'WARN, tempfile',
'log4perl.appender.tempfile' =>
'Log::Log4perl::Appender::File',
'log4perl.appender.tempfile.filename' => $tempfn,
'log4perl.appender.tempfile.layout' =>
'Log::Log4perl::Layout::PatternLayout',
'log4perl.appender.tempfile.layout.ConversionPattern' =>
'[%P:%p] %F >%c< - %m%n',
'log4perl.logger.:info' => 'INFO',
'log4perl.appender.:info' =>
'Log::Log4perl::Appender::Screen',
'log4perl.appender.:info.stderr' => 1,
'log4perl.appender.:info.layout' =>
'Log::Log4perl::Layout::PatternLayout',
'log4perl.appender.:info.layout.ConversionPattern' =>
'[%r] %F %L %c - %m%n',
});
# you can still call Log, Logf, in the old Log::Info style,
# just for migration...
Log(CHAN_INFO, LOG_ERR, 'this is an error message');
# ...but now you should use Log::Log4perl
Log::Log4perl->get_logger->warn('l1 warn');
# here we can even use the Log::Info
Log::Log4perl->get_logger(':info')->warn('l2 warn');
Each of the following channels exist by default, and have their channel level set to undef. Only CHAN_INFO has a sink by default; called SINK_STDERR (a name exported with the :default_channels tag), which is a filehandle to STDERR, and is set at level LOG_WARNING.
Each channel and sink name will be exported upon request, or together using the :default_channels tag.
Intended for progress reports, e.g., done 1 of 3 files, or 20% through.
Default level: LOG_WARNING
Intended for debugging messages, such as those you might output with --debug flag on.
Default level: LOG_WARNING
Intended for output of statistical information; e.g., found 300 items or output file is 30M, parsing took 79s.
Default level: LOG_WARNING
Intended for warning and error messages, and those that would be output by -v.
Messages that would be used with warn should be logged at level LOG_WARNING, those for a -v flag with level LOG_INFO (and LOG_DEBUG|"LOG_DEBUG" for increased verbosity).
die messages should be logged at LOG_ERR|"LOG_ERR" level. LOG_EMERG should be reserved for conditions detected which have a significant, time-critical effect on the operating system as a whole (e.g., anything which will cause the operating system to hang or crash).
LOG_ALERT should be used for conditions which may affect the correct operation of the operating system, but will not cause the system to fail (e.g., detected filesystem faults).
LOG_CRIT should be used to indicate that some problem has been identified that is likely to adversely affect the correct operation of a system (other than the operating system) of which this program is a part, not including that this program is going to fail. An example of this is an error in a shared configuration file.
LOG_NOTICE should be used for abnormal, but not worrying conditions. For example, if a grep-like program might log a message for each file read at level LOG_INFO, but log at LOG_NOTICE files which it has not permissions to read.
Here is a fine kettle of fish.
This sink sniffs its filehandle (upon sink creation), and if it smells like a TTY, it uses it as a progress bar. Otherwise, it just sets up a file/filehandle sink as usual.
In progress-bar mode, incoming messages are examined. If they look like
m!\[([\d_,.]+/[\d_,.]+|[\d_,.]+%)(\s+[^]]*)?\s+Done\]!
Then that is treated as progress information, and the bar updated accordingly.
Default translator units provided for communal edification.
(UDT => "Un*x-Date-Time"). Prefix each message with the date and time, first in Un*x (seconds since Jan 1, 1970) format, then as the scalar gmtime output. gmtime is deliberately chosen to avoid weirdness over, say, daylight-savings time changes.
Create a new channel.
chan is not already a channel name $chan =~ /^[\w-]+$/;
delete an existing channel. Implicitly deletes all attached sinks.
chan is an existing channel name
name of channel to delete
Channel name to test for
Whether the name channel is known to Log::Info
set output cutoff level on channel
Add a translator to a channel.
The channel to add the translator to.
The translator to add. The translator will be called in order after any previously added translators, and will be given the results of the log string having been through those translators. The results of the translation provided by this translator will be passed to any translators installed after this one, and to any sink-specific translators.
$chan is an existing channel name $sink =~ /^[\w-]+$/;
channel to add sink to
name of sink
sink type as string. See params for acceptable types.
Output cutoff level. Set to 'undef' to accept any messages accepted by the channel. This level is checked after the channel level; therefore, if this level is higher than the channel level, it will have no effect.
A hashref of type-specific parameters. Recognized keys are type specific:
Output to file. If the file exists, it will be appended to. Each message (call to Log) will be newline-terminated. Keys are:
Output to filehandle. Creation of, and closing of, the filehandle are the responsibility of the client. Do not delete the filehandle without closing the sink first. Each message (call to Log) will be newline-terminated. Keys are:
Filehandle to output to. May be an IO handle (*foo{IO}), a glob ref, a glob, or an instance of IO::Handle.
Callback subroutine. Keys are:
Log to syslog service. Any LOG_X value provided by this module is a valid syslog level; any level that is provided that is not valid for syslog is rounded down to the nearest value. Any level that is less than all valid values is defaulted to LOG_EMERG. The message is logged with the basename of the running script, and pid.
Due to an artifact of Sys::Syslog, messages have a space appended when they appear in the log.
Keys are:
Optional; facility to pass to syslog to log messages under. Valid values are the FTY_ constants.
Remove a sink from a channel.
set output cutoff level on channel
Add a translator to a channel sink.
The channel to add the translator to.
The sink to add the translator to.
The translator to add. The translator will be called in order after any previously added (sink-specific) translators, all of which are called after any channel translators, and will be given the results of the log string having been through those translators. The results of the translation provided by this translator will be passed to any (sink-specific) translators installed after this one.

log a message
channel to log to
message log level. Only if the log level is equal to or less than the channel log level will it be logged. For each sink, if the sink also has a level, the message will be logged to that sink only if the message level is equal to or below the sink level as well as the channel level.
The string to log. Do not append a line terminator; the sinks will do so themselves if necessary.
As for Log
As for Log
As for "sprintf" in sprintf.
As for "sprintf" in sprintf.

Add handlers to warn(), die(), to log messages to the log system. Any existing handlers are invoked after those added.
The die handler logs the message to CHAN_INFO at LOG_ERR. The warn handler logs the message to CHAN_INFO at LOG_WARNING.
This also traps Carp messages.
None
Set up output channel (for string based command-line options).
name of the channel to log to.
value of option presented by user. If this option looks like a simple number, it is treated as a log level (see below). If this option looks like a simple file name (m!^[A-Za-z0-9_.\\/-]+$), it will be treated as an output file (but output with the 'FH' type, so no auto-rotate, and special files will work). If this option looks like m!^:\d+!, the numeric value will be treated as a file descriptor, and output sent there. If this value is defined, but a blank string, then output will be sent to stderr.
If a value of the form \+\d+ precedes a file descriptor, or succeeds a filename, then the numeric value is used to set the log level of the output sink. If not set, it defaults to LOG_INFO, which is equivalent to +1. Hence, +0 is equivalent to LOG_INFO - 1.
If this value is not defined, then no action is taken (this is to allow compatibility with options processors, where a value is left undefined if its option is never invoked).
If this value is defined but empty (''), then the log level is set to LOG_INFO (first time), and the output sent to STDERR. If the option is seen again, still with an empty string value, and with the same channel & sink names, then the log level is increased one place. This is to allow -v -v -v(or -vvv)-style options.
name of the option invoked (used for error messages).
the name of the sink to create.
Optional If true, generate a sink with SINK_TERM_PROGRESS


%m strings will get expanded to $! in SYSLOG sinks; this is a bug, and may get fixed at any time.
Email the author.

Martyn J. Pearce fluffy@cpan.org

Copyright (c) 2001, 2002, 2003, 2005, 2010 Martyn J. Pearce. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
