<div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><br>
</div>I had the same dilemma with Pinto.  I wanted to log stuff from any and all objects, but I didn't want a singleton or global logger.  So I ended up passing loggers to all the constructors.  I used a role (called "Loggable") to help make each class uniform.  But I never really liked having to pass that damn logger object all over the place.<br>
<br></blockquote><div><br></div><div>The last couple codebases I've worked on, I've set it up so you can do</div><div><br></div><div>  Log->info("whatever")</div><div><br></div><div>and that "Log" class uses AUTOLOAD to catch the method gets the log4perl logger based on the caller's package something like this</div>
<div><br></div><div>       my $logger = Log::Log4perl::get_logger($caller);</div><div>        $logger->$levelname(grep {defined $_ } @args);</div><div><br></div><div>That keeps the infrastructure code you have to look at in your own stuff to a minimum. </div>
</div></div>