From c4633b20f89416b8cafa1999ccf6fef0e1dccc6a Mon Sep 17 00:00:00 2001 From: fubuloubu <3859395+fubuloubu@users.noreply.github.com> Date: Thu, 9 May 2024 23:04:07 -0400 Subject: [PATCH] refactor: move system task results to debug logger in middleware --- silverback/middlewares.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/silverback/middlewares.py b/silverback/middlewares.py index 5f1d526b..9ebe4483 100644 --- a/silverback/middlewares.py +++ b/silverback/middlewares.py @@ -96,8 +96,12 @@ def post_execute(self, message: TaskiqMessage, result: TaskiqResult): else: percent_display = "" - (logger.error if result.error else logger.success)( - f"{self._create_label(message)} " f"- {result.execution_time:.3f}s{percent_display}" - ) + msg = f"{self._create_label(message)} " f"- {result.execution_time:.3f}s{percent_display}" + if result.is_err: + logger.error(msg) + elif message.task_name.startswith("system:"): + logger.debug(msg) + else: + logger.success(msg) # NOTE: Unless stdout is ignored, error traceback appears in stdout, no need for `on_error`