Perl DBIx::LogAny replacement for DBIx::Log4perl

Whilst at YAPC::EU 2012 there was a talk which included Log::Any. I didn't attend that talk but a friend (Jens Rehsack) was and he wondered why DBIx::Log4perl wasn't DBIx::LogAny. The simple answer is that Log::Any did not exist when I wrote it and we were using Log::Log4perl.

I had plans for today but the weather was poor and so I thought I'd try a quick hack of DBIx::LogAny. You can find it here. There are 2 problems:

  1. DBIx::Log4perl (and hence DBIx::LogAny) passes closures to the log methods and Log::Any does not handle that (although Log::Log4perl does). It generally does this when the thing to be logged could be quite expensive to calculate and it avoids wrapping things in is_xxx (e.g., is_debug) methods. For now, you'll get CODE xxxx in the log instead of what you really want. I rt'ed this at log functions don't accept closures. If Jonathan Swartz does not like this request (or has some other reason for not wanting it) I'll just have to wrap all calls in is_xxx functions.
  2. DBIx::Log4perl (and hence DBIx::LogAny) uses Log::Log4perl's caller_depth so that logging the location of the log message refers to the user code and not DBIx::LogAny. I cannot find a way of doing this with Log::Any even if you are using Log::Log4perl under the hood.