Dear LazyPerl, looking for a logger
I'm looking for a logger module like Log::Log4Perl but one I can hand a filename to and be done with it. No /etc configuration files or other crap to deal with, and still have debug/warn/etc log levels.
Any ideas? Something like:
use Log::EasyLog;
my $logger = Log::EasyLog->new( file => '/tmp/mylogfile' );
Try Log::Any::App.
To set log level from within the script:
To set log level from outside the script, set LOG_LEVEL=debug.
Take a look at https://github.com/daotoad/Log-Lager
I was recently looking for a logging library with the same criteria and someone pointed me to Log::Dispatch. Check it out ...
You gotta be kiddin' me! :)
Two blog entries ago in this exact blog site I wrote about a logging module... seriously, dude.
Check out Log::Dispatchouli which is a freakin' awesome wrapper around Log::Dispatch. It supports levels, syslog, prefixes, output to files, stdout, stderr, etc.
And if you're using it with Moose/Mouse/etc. MooseX::Role::Loggable might be of value.
Read the blog post: https://blogs.perl.org/users/sawyer_x/2012/01/i-love-moosexroleloggable.html.
@Steven and @Al, thanks for the great links, just what I was looking for. @offby1 that looks interesting but I need something on CPAN. @SawyerX, thanks for the links also, but those are a little more full featured than what I was looking for. Trying to keep it simple, and not involve Moose or any other things I won't need.
What is wrong with
taken right from perldoc Log::Log4perl?
If you want, you can get a normal logger after easy_init and use it too:
I think easy_init() is easy enough and I used to use it a lot.
But since a couple of years ago I started writing most code in modules instead of scripts, and Log::Log4perl complains with "Log4perl: Seems like no initialization happened. Forgot to call init()?". It's also a turn-off for some module users if I use Log4perl inside my modules. So I've been using Log::Any instead.