Skip to content

Commit

Permalink
Function to add a decorator to all functions in a class
Browse files Browse the repository at this point in the history
  • Loading branch information
Rishabh Ranjan committed Aug 25, 2024
1 parent c187e9a commit 7dc1e9a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions invesalius/gui/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,9 @@ def flushHandlers(self):
for handler in self._logger.handlers:
handler.flush()

#####################################################################################
# Decorators for logging

def call_tracking_decorator(fileName, className, functionName=''):
def decorator(func):
def wrapper(*args, **kwargs):
Expand All @@ -324,6 +327,12 @@ def wrapper_accepting_arguments(*args):

return wrapper_accepting_arguments

class DecorateAllMethods:
def __init_subclass__(cls, **kwargs):
super().__init_subclass__(**kwargs)
for attr, value in cls.__dict__.items():
if callable(value):
setattr(cls, attr, call_tracking_decorator00(value))

#####################################################################################
# Decorators for error handling
Expand Down

0 comments on commit 7dc1e9a

Please sign in to comment.