Subject: | log functions don't accept closures |
I'm not sure if you'd class this a bug or an enhancement. I use
Log::Log4perl all the time and had a request to change DBIx::Log4perl to
DBIx::LogAny. However, I've hit a problem as a lot of the code does:
$log->debug(sub {something_expensive});
e.g.
$log->debug(sub {Dumper($x)});
which results in the log file like this:
[Sun Oct 28 12:21:21 2012] CODE(0x2986758)
Log::Log4perl allows the closure and expands it. It is useful as the
expression does not get evaled if logging is disabled.
See
http://search.cpan.org/~mschilli/Log-Log4perl-1.39/lib/Log/Log4perl.pm#Penalties
Would you consider making this work. If you don't the only way around
this I see is to put is_debug etc around all of these which I'd rather
not do because a) there is a lot of them b) it will penalise
DBIx::Log4perl which shares the same code base.
BTW, 2 other observations:
1) in the pod on cpan, the links in Log::Any::Adapter below "Adapters in
this distribution" don't work.
2) you probably think it is obvious but I did a set('File', 'x.log') and
got an error saying autoflush could not be found via IO::File. It might
be worth mentioning you need to use IO::File before setting File (at
least in Log::Any::Adapter::File). This might have been slightly more
obvious if (1) was not broken as one of the links I guess should be to
IO::File or Log::Any::Adapter::File.
Martin
--
Martin J. Evans
Wetherby, UK