- ADAPTER METHODS
- SEE ALSO
- COPYRIGHT AND LICENSE
Log::Any::Plugin::Levels - Logging-level filtering plugin for log adapters
# 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
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.
Configuration values are passed as key-value pairs when adding the plugin: Log::Any::Plugin->add('Levels', level => 'debug', accessor => 'my_level');
The global log level, which defaults to 'warning'. See the level method below for a discussion on how this is applied.
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.
There are no methods in this package which should be directly called by the user. Use Log::Any::Plugin->add() instead.
Private method called by Log::Any::Plugin->add()
The following methods are injected into the adapter class.
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'.
Thanks to Strategic Data for sponsoring the development of this module.
Stephen Thirlwall <email@example.com>
This software is copyright (c) 2019, 2017, 2016, 2015, 2014, 2013, 2011 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.