From a3cc29ca3c73c24a6ef038eb95bf9a6f94d2c4e1 Mon Sep 17 00:00:00 2001 From: Goffi Date: Wed, 12 Aug 2026 18:12:02 +0200 Subject: [PATCH] cli (debug/monitor): Add timestamp to XML logs. --- libervia/cli/cmd_debug.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/libervia/cli/cmd_debug.py b/libervia/cli/cmd_debug.py index 5413e875..4db37902 100644 --- a/libervia/cli/cmd_debug.py +++ b/libervia/cli/cmd_debug.py @@ -21,8 +21,9 @@ from . import base from libervia.backend.core.i18n import _ from libervia.cli.constants import Const as C -from libervia.backend.tools.common.ansi import ANSI as A +from libervia.backend.tools.common.date_utils import date_fmt import json +import time __commands__ = ["Debug"] @@ -159,17 +160,14 @@ class Monitor(base.CommandBase): if verbosity: profile_disp = f" ({profile})" if verbosity > 1 else "" + ts = date_fmt(time.time(), fmt="HH:mm:ss.SSS") if direction == "IN": - self.disp( - A.color( - A.BOLD, A.FG_YELLOW, "<<<===== IN ====", A.FG_WHITE, profile_disp - ) + self.console.print( + f"[bold yellow]<<<===== IN ===== [{ts}][/bold yellow]{profile_disp}" ) else: - self.disp( - A.color( - A.BOLD, A.FG_CYAN, "==== OUT ====>>>", A.FG_WHITE, profile_disp - ) + self.console.print( + f"[bold cyan]==== OUT ====>>> [{ts}][/bold cyan]{profile_disp}" ) if whiteping: self.disp("[WHITESPACE PING]") @@ -177,9 +175,9 @@ class Monitor(base.CommandBase): try: await self.output(xml_data) except Exception: - #  initial stream is not valid XML, + # initial stream is not valid XML, # in this case we print directly to data - #  FIXME: we should test directly lxml.etree.XMLSyntaxError + # FIXME: we should test directly lxml.etree.XMLSyntaxError # but importing lxml directly here is not clean # should be wrapped in a custom Exception self.disp(xml_data)