diff --git a/devices/src/hardware_device.py b/devices/src/hardware_device.py index 2e198b78f2a6a9bfd00100c00a30f235c9a62f5c..2f11b673149fc2484b3315dd3eaf260161657b89 100644 --- a/devices/src/hardware_device.py +++ b/devices/src/hardware_device.py @@ -61,7 +61,7 @@ class hardware_device(Device): self.value_dict = {i: i.initial_value() for i in self.attr_list()} - @log_exceptions + @log_exceptions() def init_device(self): """ Instantiates the device in the OFF state. """ @@ -165,7 +165,7 @@ class hardware_device(Device): """Method always executed before any TANGO command is executed.""" pass - @log_exceptions + @log_exceptions() def delete_device(self): """Hook to delete resources allocated in init_device. diff --git a/devices/src/lofar_logging.py b/devices/src/lofar_logging.py index cf43235eb4d56d729f2e690125cd15a9ba884b57..aa7d3633138679c63fd1934cf8d5638df7b1cedf 100644 --- a/devices/src/lofar_logging.py +++ b/devices/src/lofar_logging.py @@ -54,15 +54,18 @@ def device_logging_to_python(log_extra: dict = None): return inner -def log_exceptions(func): +def log_exceptions(): """ Decorator that logs all exceptions that the function raises. """ - @wraps(func) - def inner(self, *args, **kwargs): - try: - return func(self, *args, **kwargs) - except Exception as e: - self.error_stream("Caught exception: %s: %s", e.__class__.__name__, e, exc_info=1) - raise e + def wrapper(func): + @wraps(func) + def inner(self, *args, **kwargs): + try: + return func(self, *args, **kwargs) + except Exception as e: + self.error_stream("Caught exception: %s: %s", e.__class__.__name__, e, exc_info=1) + raise e - return inner + return inner + + return wrapper