http://www.perlmonks.org?node_id=807637


in reply to Is there some standard for logging from within the modules?

I have just come across the same problem. The way I solved it is that I simply created a log method in my module and I pass the messages to it. The method stores the messages in the object.

It is fairly easy for users to redefine the method (directly or by subclassing).

sub log { my ($self, $msg) = @_; push @{ $self->{log} }, { timestamp => time, message => $msg, }; } sub foo { my ($self) = @_; $self->log('Entered foo'); }
use strict; use warnings; print "Just Another Perl Hacker\n";