From 61e5c9599dc9292a99dc328264d7f8a9ccd811eb Mon Sep 17 00:00:00 2001 From: Jan David Mol <mol@astron.nl> Date: Sun, 4 Apr 2021 23:11:06 +0200 Subject: [PATCH] Use () syntax behind wrappers for consistency with Tango/SKA wrappers --- devices/src/hardware_device.py | 4 ++-- devices/src/lofar_logging.py | 21 ++++++++++++--------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/devices/src/hardware_device.py b/devices/src/hardware_device.py index 2e198b78f..2f11b6731 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 cf43235eb..aa7d36331 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 -- GitLab