Log::Log4perl::Shortcuts - shortcut functions to make log4perl even easier
version 0.006
Provides an easy-to-use wrapper for Log::Log4perl.
Instead of this:
use Log::Log4perl; sub do_something { my $logger = Log::Log4perl->get_logger('my.category'); $log->info('I am doing something.'); }
You can save some keystrokes and do this:
use Log::Log4perl::Shortcuts qw(:all); sub do_something { logw('I am doing something.', 'my.category'); }
This modules provides shortcut functions for the standard log levels provided by Log::Log4perl plus some additional functionality to make it more convenient.
There are the six log level functions provided, one for each of the standard log levels provided by the Log4perl module. Each of them accepts an argument for the log message plus an optional category argument.
The $category arguments, if supplied, are appended to the name of the calling package where the log command was invoked. For example, if logi('Info log entry', 'my_category') is called from package Foo::Bar, the log entry will be made with the category:
logi('Info log entry', 'my_category')
Foo::Bar
Foo::Bar.my_category
Prints a message to the trace logger when the log level is set to TRACE or above.
Print messages when the log level is set to DEBUG or above. $category argument is optional.
$msg is intended to be a scalar variable or reference to a data structure which will be output as a message after getting passed through Data::Dumper.
Prints a message to the info logger when the log level is set to INFO or above.
Prints a message to the warn logger when the log level is set to WARN or above.
Prints a message to the error logger when the log level is set to ERROR or above.
Prints a message to the fatal logger when the log level is set to FATAL or above.
Prints call stack when log level is set to TRACE or above. Note that no message argument is used by this function.
Changes the log configuration file which must be placed in the ~/perl/log_config directory.
~/perl/log_config
Place any custom log configuration files you'd like to use in ~/perl/log_config and use the change_config_file function to switch to it.
change_config_file
Carp
Data::Dumper
Exporter
File::HomeDir
Log::Log4perl
You can find documentation for this module with the perldoc command.
perldoc Log::Log4perl::Shortcuts
The following websites have more information about this module, and may be of help to you. As always, in addition to those websites please use your favorite search engine to discover more resources.
MetaCPAN
A modern, open-source CPAN search engine, useful to view POD in HTML format.
https://metacpan.org/release/Log-Log4perl-Shortcuts
The code is open to the world, and available for you to hack on. Please feel free to browse it and play with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull from your repository :)
https://github.com/sdondley/Log-Log4perl-Shortcuts
git clone git://github.com/sdondley/Log-Log4perl-Shortcuts.git
You can make new bug reports, and view existing ones, through the web interface at http://github.com/sdondley/Log-Log4perl-Shortcuts/issues.
See perlmodinstall for information and options on installing Perl modules.
Steve Dondley <s@dondley.com>
This software is copyright (c) 2018 by Steve Dondley.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Log::Log4perl::Shortcuts, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Log::Log4perl::Shortcuts
CPAN shell
perl -MCPAN -e shell install Log::Log4perl::Shortcuts
For more information on module installation, please visit the detailed CPAN module installation guide.