Amphibic::Log - Because logging should be fun
version 0.02
# In webapp.pl my $logger = Amphibic::Log->new (name => "webapp"); $logger->info ("Authentication failure"); # In a shell far, far away $ export LOG_TRACE=1 $ perl webapp.pl
Logging should be a simple thing that everyone do. Yet, few modules if any actually do logging. And many that actually do logging has invented their own logging scheme. The problem isn't dependencies on other modules, but the fact that most logging modules get some fundamental assumptions about where they will be used wrong. This is my attempt at making logging easy and not something to be avoided, even when faced with real world situations like time constraints and lack of planning.
This module is hardcoded with six fairly standard logging levels, namely "fatal", "error", "warn", "info", "debug", and "trace". This module behaves so that enabling a given level in the list above also enables every level before it. Ie, if you enable "trace", you also enable every single other level.
At the moment, only logging to STDERR is supported. Yes, this is going to change, I just want to focus on getting other things right first before adding support for more destinations.
To enable logging of all messages:
export LOG_TRACE=1
Or if you are not using bash, use the equivalent command for setting an environment variable in your shell. To enable a given level, set the environment variable LOG_<level> to a true value.
Identify the component name the log messages are coming from. This should be a simple identifier; If the logging entity was DBIx::Class then the identifier should probably be something like "dbic".
# $log->is_debug;
Returns a true value if the current logging level is at least at this level. The purpose of these methods is usually so the programmer can avoid running things like expensive debugging routines if it isn't necessary.
# $log->debug ($message);
Sends $message to the underlying transports.
Most software has bugs. This module probably isn't an exception. If you find a bug please either email me, or add the bug to cpan-RT.
Anders Nor Berle <berle@cpan.org>
This software is copyright (c) 2010 by Anders Nor Berle.
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 Amphibic::Log, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Amphibic::Log
CPAN shell
perl -MCPAN -e shell install Amphibic::Log
For more information on module installation, please visit the detailed CPAN module installation guide.