Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: Is there some standard for logging from within the modules?

by Sixtease (Friar)
on Nov 17, 2009 at 09:31 UTC ( #807637=note: print w/replies, xml ) Need Help??

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";

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://807637]
[davido]: I find it annoying when I see "People tend to average between X and Y.", that's not an average, that's a range.
[Corion]: Ask about the median ;)
[jdporter]: posts like this one make me realize, ruefully, just how much my mind has deteriorated in recent years/months.
[jdporter]: "When all your nails look like trolls, all your hammers look like trolls."

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (9)
As of 2018-06-21 16:21 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (118 votes). Check out past polls.