Develop:a good start point for debug and log

odwlib/debug/debug.py

It is a good start point for debug and log. It can trace classes and functions. 
Run odwlib/debug/debugTest.py to test it.

Copyright (c) by Kevin L. Sitze on 2011-01-23.
This code may be used pursuant to the MIT License.

@author:  Kevin L. Sitze
          modified by: hongloull

usage:

import owlib.debug.debug as debug

@debug.debug
def function(...):
    '''Output goes to <TT>logging.getLogger(__module__)</TT>,
    where <TT>__module__</TT> is the name of the module in which
    the function is defined.  If the current module is '__main__'
    then the root logger will be used.
    '''
    pass

@debug.debug(logger)
def function(...):
    '''Output goes to the specified logger instance.
    '''
    pass

@debug.debug("Logger")
def function(...):
    '''Output goes to the named logger instance.
    '''

class ClassName(object):
    '''Output goes to the ClassName logger.  If ClassName is
    not in the '__main__' module then the name of its module
    will be prefixed to the classname (separated by a dot).
    All methods on the class will be debugd.
    '''
    __logger__ = debug.loggerOrLoggerName # optional
    __metaclass__ = debug.TraceMetaClass
    def method(...):
        pass

class PostDecorate(object):
    def method(...):
        pass
# attach a decorator to an existing class.
debug.attach(debug.debug(logger), PostDecorate)

You can also attach a decorator to an existing module.