I need a logging module with a simple interface, for logging messages from multiple processes to a common local log file.
Since some of these processes may be running simultaneously, the logging module must manage conflicting write requests from these process.
I know about Log::Log4perl
, but every time I try to use it I end up with an inordinately complex logging interface. I'm looking for an alternative. Any suggestions?
I looked into Log::Message
, which is AFAICT the only logging module included among Perl's core modules (sadly enough, IMO). I found no indication that it handles concurrency at all.
I also tried searching CPAN for an alternative, but just searching for 'Log::' under Modules produced over 3000 hits, in no particular order. Even scanning this list is impractical, let alone reading the documentation for the possible candidates, and trying out those that seem promising. (I wonder if the very difficulty of finding a reasonable logging module in CPAN is what gets people to roll their own, which they submit later to CPAN, thus adding one more item to the already unsurmountable mountain of logging modules. IOW, we may have a case of runaway growth here.)
I'm looking for a simple interface. Ideally, all the setup (e.g. the path to the log file, log level, etc.) would be done via a globally-shared ~/.*rc
-type config file and/or environment variables.
Here's an example of what I mean by "a simple interface" (though, of course, I don't expect that I'll find a module out there that offers this exact interface; and, of course also, EasyLog
is a made-up name; if a module by that name already exists, it is a coincidence):
#!/usr/bin/env perl
# some/script.pl
use strict;
use EasyLog ':all';
...
DEBUG "cwd: " + Cwd::cwd();
...
WARN "skipping empty line $.";
...
FATAL "timeout"; # maybe calls exit ?
Then, in some file $ENV{ EASYLOG_PATH }
, I'd see lines like
30031 1430599390 /path/to/some/script.pl 2 INFO Starting script.pl on Sat May 2 16:43:10 2015
30031 1430599429 /path/to/some/script.pl 19 WARN skipping empty line 898
30036 1430599542 /path/to/some/script.pl 2 INFO Starting script.pl on Sat May 2 16:45:42 2015
30031 1430599583 /path/to/some/script.pl 94 INFO script.pl terminated normally on Sat May 2 16:46:23 2015
30036 1430599583 /path/to/some/script.pl 32 FATAL timeout