From 8ec9b05fe6ab984b6852d416780367a2aa5ef3d7 Mon Sep 17 00:00:00 2001
From: leufen1 <l.leufen@fz-juelich.de>
Date: Mon, 19 Apr 2021 10:19:56 +0200
Subject: [PATCH] TrackParameter wraps now entire method to get the return
 value

---
 mlair/helpers/datastore.py | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/mlair/helpers/datastore.py b/mlair/helpers/datastore.py
index d6c977c7..b08c6f45 100644
--- a/mlair/helpers/datastore.py
+++ b/mlair/helpers/datastore.py
@@ -111,8 +111,15 @@ class TrackParameter:
         """
         Call method of decorator.
         """
-        self.track(*args)
-        return self.__wrapped__(*args, **kwargs)
+        name, obj, scope = self.track(*args)
+        f_name = self.__wrapped__.__name__
+        try:
+            res = self.__wrapped__(*args, **kwargs)
+            logging.debug(f"{f_name}: {name}({scope})={res if obj is None else obj}")
+        except Exception as e:
+            logging.debug(f"{f_name}: {name}({scope})={obj}")
+            raise
+        return res
 
     def __get__(self, instance, cls):
         """Create bound method object and supply self argument to the decorated method. <Python Cookbook, p.347>"""
@@ -127,6 +134,7 @@ class TrackParameter:
             tracker[name].append(new_entry)
         else:
             tracker[name] = [new_entry]
+        return name, obj, scope
 
     @staticmethod
     def _decrypt_args(*args):
-- 
GitLab