the ultimate logging facility for debugging code

Jean-Michel Pichavant jeanmichel at sequans.com
Fri Jul 10 05:39:54 EDT 2009


Greetings,

Sorry for the dubious title :o). I was wandering if there is a standard 
(or reliable) python module that implements the following feature:

http://code.activestate.com/recipes/198078/
 >>>Recipe 198078: Wrapping method calls (meta-class example)
 >>>
 >>>A metaclass is used to wrap all (or just some) methods for logging 
purposes. The underlying mechanism can be used as well to check pre/post 
conditions, attribute access,... The basic point is, that the actual 
class must not be changed in any way to achive the desired effect.
   

I had to adapt the code to some of my needs, but now it's almost 
working, by simply defining a metaclass for any of my class, I get the 
class methods calls logged with the instance that called the method, the 
method name, the call line in the file, the parameter **value**  passed 
to the method and the returned value.
It just saved me from hours of ipython interactive debugging with the 
old print way, and to beauty of it: I don't have to write any 
"self._log('Please log me')" line.

As it is so useful, I bet there is a module that is doing this in a more 
reliable way that I did. Anyone has heard of it ?

Jean-Michel




More information about the Python-list mailing list