Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def debug_all_class_methods(cls):
- """
- This class decorator attempts to log each time a function is referenced.
- This should help in debugging the flow of the process.
- If you don't want these messages, set the logging level above the debug level.
- :param cls: The class you are decorating.
- :return: Printing all the things.
- """
- class NewClass(object):
- def __init__(self, *args, **kwargs):
- self.oInstance = cls(*args, **kwargs)
- def __getattribute__(self, s):
- try:
- x = super(NewClass, self).__getattribute__()
- except AttributeError:
- pass
- else:
- return x
- x = self.oInstance.__getattribute__(s)
- if callable(x):
- if self.oInstance.logger:
- self.oInstance.logger.debug("Entering %s", x.__name__)
- return x
- return NewClass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement