From f681e5ec3264c79ccc9afff8d8845bafccdac458 Mon Sep 17 00:00:00 2001 From: "didierlopes.eth" Date: Thu, 27 Jan 2022 15:35:29 +0000 Subject: [PATCH] Methods logging for controllers (#1268) * methods logging for controllers * follow James suggestion --- gamestonk_terminal/decorators.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gamestonk_terminal/decorators.py b/gamestonk_terminal/decorators.py index a28ef823d9a..749062abfb3 100644 --- a/gamestonk_terminal/decorators.py +++ b/gamestonk_terminal/decorators.py @@ -52,13 +52,18 @@ def log_start_end(func=None, log=None): @functools.wraps(func) def wrapper(*args, **kwargs): + kwargs_passed_in_function = list() args_passed_in_function = [repr(a) for a in args] # view files have parameters that are usually small given they are input by the user - if log.name[-5:] == "_view": + if "_view" in log.name: kwargs_passed_in_function = [f"{k}={v!r}" for k, v in kwargs.items()] + # we are only interested in the other_args from controller methods + elif "_controller" in log.name: + # check len of args is 2 because of (self, other_args: List[str]) + if len(args) == 2: + args_passed_in_function = args[1] # other files can have as parameters big variables, therefore adds logic to only add small ones else: - kwargs_passed_in_function = list() for k, v in kwargs.items(): if type(v) in (int, float): kwargs_passed_in_function.append(f"{k}={v!r}")