NAME

FU::Log - Extremely Basic Process-Wide Logging Infrastructure

EXPERIMENTAL

This module is still in development and there will likely be a few breaking API changes, see the main FU module for details.

SYNOPSIS

use FU::Log 'log_write';

FU::Log::capture_warn(1);
FU::Log::set_file('/var/log/mylog.log');

DESCRIPTION

This module doesn't do a whole lot. Its main purpose is to have a centrally-configured logging facility so that modules can log stuff and an application can configure where those logs should end up.

There's no log levels or filtering; the what to log question is better answered with separate configuration options per module. There's no OO-style interface either; the entire point of this module is that it only handles process-global logging. This module mainly exists for users of the FU framework.

Configuration

FU::Log::set_file($path)

Set the path to write logs to.

If no path is configured or if $path is undef, logs are written to STDERR. If $path is -, logs are written to STDOUT.

When writing to file, logs are still replicated to STDERR if that is a TTY.

FU::Log::capture_warn($enabled)

Whether to capture Perl warn messages.

FU::Log::set_fmt($sub)

Subroutine to call to format the log messages. Is given a log message as Unicode string as first argument and should return a formatted Unicode string.

The given message may include newlines, it is up to the formatting function to decide how to log that.

This function is not called when inside log_write(), the default log format is then used instead. This is to avoid recursion.

Exportable function

log_write($msg)

Write a message to the log.

COPYRIGHT

MIT.

AUTHOR

Yorhel <projects@yorhel.nl>