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 separation/factoring out logging from a class would provide more
elegant and cleaner code, for example by not requiring a method
dispatcher capable of logging. The question is, how can it be done?
Please share your thoughts and ideas on this issue.
Thank you in advance,
Balint Szilakszi [english spelling]
Szilakszi Bálint [hungarian spelling]
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 <nothi...@woobling.org>
http://nothingmuch.woobling.org 0xEBD27418