From 1c7ef048f162860eb8dbc4c6210226345cf5ebab Mon Sep 17 00:00:00 2001 From: harvey_xiang Date: Fri, 26 Dec 2025 10:30:06 +0800 Subject: [PATCH] feat: add timer log --- src/memos/utils.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/memos/utils.py b/src/memos/utils.py index b57967db0..594180e8f 100644 --- a/src/memos/utils.py +++ b/src/memos/utils.py @@ -1,5 +1,6 @@ import functools import time +import traceback from memos.log import get_logger @@ -35,6 +36,7 @@ def decorator(fn): def wrapper(*args, **kwargs): start = time.perf_counter() exc_type = None + exc_message = None result = None success_flag = False @@ -44,6 +46,7 @@ def wrapper(*args, **kwargs): return result except Exception as e: exc_type = type(e) + exc_message = traceback.format_exc() success_flag = False if fallback is not None and callable(fallback): @@ -76,13 +79,15 @@ def wrapper(*args, **kwargs): status = "SUCCESS" if success_flag else "FAILED" status_info = f", status: {status}" - if not success_flag and exc_type is not None: - status_info += f", error: {exc_type.__name__}" + status_info += ( + f", error_type: {exc_type.__name__}, error_message: {exc_message}" + ) msg = ( f"[TIMER_WITH_STATUS] {log_prefix or fn.__name__} " f"took {elapsed_ms:.0f} ms{status_info}, args: {ctx_str}" + f", result: {result}" ) logger.info(msg)