NAME

Acme::Crux::Plugin::Log - The Acme::Crux plugin for logging in your application

SYNOPSIS

# In startup
$app->plugin('Log');
$app->plugin('Log', undef, { ... options ... });

# In application
$app->log->trace('Whatever');
$app->log->debug('You screwed up, but that is ok');
$app->log->info('You are bad, but you prolly know already');
$app->log->notice('Normal, but significant, condition...');
$app->log->warn('Dont do that Dave...');
$app->log->error('You really screwed up this time');
$app->log->fatal('Its over...');
$app->log->crit('Its over...');
$app->log->alert('Action must be taken immediately');
$app->log->emerg('System is unusable');

DESCRIPTION

The Acme::Crux plugin for logging in your application

OPTIONS

This plugin supports the following options

autoclean

$app->plugin(Log => undef, {autoclean => 1});

This option enables cleaning (closing handler or syslog) on DESTROY

Default: logautoclean command line option or logautoclean application argument or LogAutoclean configuration value or 0 otherwise

color

$app->plugin(Log => undef, {color => 1});

This option enables colorize log messages with the available levels using Term::ANSIColor

Default: logcolorize command line option or logcolorize application argument or LogColorize configuration value or 0 otherwise

facility

$app->plugin(Log => undef, {facility => 'user'});

This option 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: logfacility command line option or logfacility application argument or LogFacility configuration value or user otherwise

file

$app->plugin(Log => undef, {file => '/var/log/myapp.log'});

Log file path used by "handle"

Default: logfile command line option or LogFile configuration value or logfile application argument or /var/log/$moniker/$moniker.log otherwise

format

$app->plugin(Log => undef, {format => sub {...}});

A callback function for formatting log messages. See "format" in Acrux::Log

Default: logformat application argument or undef otherwise

handle

$app->plugin(Log => undef, {
    handle => IO::Handle->new_from_fd(fileno(STDOUT), "w")
});

Log filehandle, defaults to opening "file" or uses syslog if file not specified

Default: loghandle application argument or undef otherwise

ident

$app->plugin(Log => undef, {ident => 'myapp'});

The ident is prepended to every syslog message

Default: logident command line option or logident application argument or LogIdent configuration value or script name basename($0) otherwise

level

$app->plugin(Log => undef, {level => 'debug'});

This option sets log level

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.

See also "level" in Acrux::Log

Default: loglevel command line option or loglevel application argument or LogLevel configuration value or debug otherwise

logger

$app->plugin(Log => undef, {logger => Mojo::Log->new()});

This option sets predefined logger, eg. Mojo::Log

Default: logger application argument or undef otherwise

logopt

$app->plugin(Log => undef, {logopt => 'ndelay,pid'});

This option contains zero or more of the options detailed in "openlog" in Sys::Syslog

Default: logopt command line option or logopt application argument or LogOpt configuration value or 'ndelay,pid' otherwise

prefix

$app->plugin(Log => undef, {prefix => '>>>'});

The prefix is prepended to every handled log message

Default: logprefix command line option or logprefix application argument or LogPrefix configuration value or null otherwise

provider

$app->plugin(Log => undef, {provider => 'syslog'});

This option select the provider of logging. Avalabled providers: logger, handler, file and syslog.

Default: logprovider command line option or logprovider application argument or LogProvider configuration value or file otherwise

short

$app->plugin(Log => undef, {short => 1});

Generate short log messages without a timestamp but with log level prefix

Default: logshort command line option or logshort application argument or LogShort configuration value or 0 otherwise

METHODS

This class inherits all methods from Acme::Crux::Plugin and implements the following new ones

register

$plugin->register($app, {file => '/var/log/app.log'});

Register plugin in Acme::Crux application

HELPERS

All helpers of this plugin are allows get access to logger object. See Acrux::Log for details

log

Returns Acrux::Log object

TO DO

See TODO file

SEE ALSO

Acme::Crux::Plugin, Acrux::Log

AUTHOR

Serż Minus (Sergey Lepenkov) https://www.serzik.com <abalama@cpan.org>

COPYRIGHT

Copyright (C) 1998-2024 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/