Automatic Logging

Peter Hansen peter at engcorp.com
Thu Jan 26 18:49:58 EST 2006


daftspaniel at gmail.com wrote:
> Sorry if this is a FAQ but Google returns a *lot* of results for Python
> Logging :-)
> 
> I am looking for a tool that will automatically add logging to existing
> code e.g. Function Entries and Exits, Return values etc.

Perhaps you are looking for nothing more than this standard function:

 >>> help(sys.settrace)
Help on built-in function settrace in module sys:

settrace(...)
     settrace(function)

     Set the global debug tracing function.  It will be called on each
     function call.  See the debugger chapter in the library manual.


Combine that with the standard library "logging" package and it meets 
your specs as stated above.

-Peter




More information about the Python-list mailing list