develooper Front page | perl.perl6.language | Postings from June 2006

Re: Classy logging for Classes

Thread Previous
Yuval Kogman
June 22, 2006 10:26
Re: Classy logging for Classes
Message ID:
On Thu, Jun 22, 2006 at 19:19:47 +0200, Szilakszi Bálint wrote:
> I'm trying to collect ideas about how could be (optionally available) logging added/implemented for classes, as in logging what methods are called at runtime, the parameters they are called 
> with, etc. without embedding the whole logic in the methods themselves on a one-by-one basis.

When the meta object protocol is exposed this will likely be a very
simple meta-class mixin role.

> What I'm specifically looking for would be an instance based idea, so it doesn't permanently overwrite the class and thus consequently switch logging on everywhere that class is used, only for 
> the scope of a given instance of the class.

This can probably be hacked at runtime by reblessing the object into
a temporarily role-mixed meta class.

That said, most of the useful logging i've seen is not automatically
generated. Traces are easy to do like this, but high quality logs
should be hand rolled so that they convey the most meaningful
representation of information.

For this, aspect oriented programming can help you separate the
logging from the actual body of the method, but this is not always
the most "correct" behavior.

  Yuval Kogman <>  0xEBD27418

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About