I use Log::Dispatch frequently to set up both file and email logging.  In
the past I have also used it with Data::Dumper for logging in debug mode
doing something like:

 

$dispatcher->log(level => 'debug', message
=>sprintf("%s",Data::Dumper(\$somevar)));

 

This makes logging hashes, arrays, objects, etc. very easy with no fuss, but
it occurs to me that this is probably terribly inefficient since the entire
contents of the variable being dumped are shoved into a string first,
(effectively doubling the memory usage).

 

I'm currently working on a project that can pull back a fairly large table
from a database and would like to do something similar (at the debug log
level only) and was just wondering if there were a more efficient way to
pass the output of Data::Dumper to Log::Dispatch.

 

-Dan

Reply via email to