NAME

Log::Any::Plugin::Levels - Logging-level filtering plugin for log adapters

VERSION

version 0.007

SYNOPSIS

# Set up some kind of logger.
use Log::Any::Adapter;
Log::Any::Adapter->set('SomeAdapter');

# Apply the Levels plugin to your logger
use Log::Any::Plugin;
Log::Any::Plugin->add('Levels', level => 'debug');


# In your modules
use Log::Any qw($log);

$log->trace('trace'); # this log is ignored
$log->error('error'); # this log gets through

$log->level('trace');
$log->trace('trace'); # this gets through now

DESCRIPTION

Log::Any leaves the decision of which log levels to ignore and which to actually log down to the individual adapters. Many adapters simply log everything.

Log::Any::Plugin::Levels allows you to add level filtering functionality into any adapter. Logs lower than $log->level are ignored.

The $log->is_debug family of functions are modified to reflect this level.

NAME

Log::Any::Plugin::FilterArgs - custom log-level filtering for log adapters

CONFIGURATION

Configuration values are passed as key-value pairs when adding the plugin: Log::Any::Plugin->add('Levels', level => 'debug', accessor => 'my_level');

level => $default_level

The global log level, which defaults to 'warning'. See the level method below for a discussion on how this is applied.

accessor => $accessor_name

This is the name of the $log->level accessor function.

The default value is 'level'. This can be changed to avoid any name clashes that may occur. An exception will be thrown in the case of a name clash.

METHODS

There are no methods in this package which should be directly called by the user. Use Log::Any::Plugin->add() instead.

install

Private method called by Log::Any::Plugin->add()

ADAPTER METHODS

The following methods are injected into the adapter class.

level( [ $log_level ] )

Accessor for the current log level in the calling $log object.

All $log objects start with the default level specified when adding the plugin. Individual $log objects can set a custom level with this accessor.

To reset to the default log level, specify 'default'.

SEE ALSO

Log::Any::Plugin

ACKNOWLEDGEMENTS

Thanks to Strategic Data for sponsoring the development of this module.

AUTHOR

Stephen Thirlwall <sdt@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by Stephen Thirlwall.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.