From 3c04625381fd3def7a9e48dd9d611fce3c1b407d Mon Sep 17 00:00:00 2001 From: wt Date: Mon, 29 Nov 2021 19:50:06 +0800 Subject: [PATCH] [skip ci] Update codes of log output (#12329) Signed-off-by: wangting0128 --- tests/python_client/utils/api_request.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/python_client/utils/api_request.py b/tests/python_client/utils/api_request.py index 8d4194c55d..838d47c4b0 100644 --- a/tests/python_client/utils/api_request.py +++ b/tests/python_client/utils/api_request.py @@ -2,8 +2,10 @@ import traceback import os from utils.util_log import test_log as log -enable_traceback = os.getenv('ENABLE_TRACEBACK', "True") -log.info(f"enable_traceback:{enable_traceback}") +# enable_traceback = os.getenv('ENABLE_TRACEBACK', "True") +# log.info(f"enable_traceback:{enable_traceback}") + + class Error: def __init__(self, error): self.code = getattr(error, 'code', -1) @@ -18,7 +20,8 @@ def api_request_catch(): def inner_wrapper(*args, **kwargs): try: res = func(*args, **kwargs) - if enable_traceback == "True": + # if enable_traceback == "True": + if kwargs.get("enable_traceback", True): res_str = str(res) log_res = res_str[0:log_row_length] + '......' if len(res_str) > log_row_length else res_str log.debug("(api_response) : %s " % log_res) @@ -27,7 +30,8 @@ def api_request_catch(): except Exception as e: e_str = str(e) log_e = e_str[0:log_row_length] + '......' if len(e_str) > log_row_length else e_str - if enable_traceback == "True": + # if enable_traceback == "True": + if kwargs.get("enable_traceback", True): log.error(traceback.format_exc()) log.error("(api_response) : %s" % log_e) return Error(e), False