cli (debug/monitor): Add timestamp to XML logs.

This commit is contained in:
Goffi 2026-08-12 18:12:02 +02:00
commit a3cc29ca3c

View file

@ -21,8 +21,9 @@
from . import base from . import base
from libervia.backend.core.i18n import _ from libervia.backend.core.i18n import _
from libervia.cli.constants import Const as C 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 json
import time
__commands__ = ["Debug"] __commands__ = ["Debug"]
@ -159,17 +160,14 @@ class Monitor(base.CommandBase):
if verbosity: if verbosity:
profile_disp = f" ({profile})" if verbosity > 1 else "" profile_disp = f" ({profile})" if verbosity > 1 else ""
ts = date_fmt(time.time(), fmt="HH:mm:ss.SSS")
if direction == "IN": if direction == "IN":
self.disp( self.console.print(
A.color( f"[bold yellow]<<<===== IN ===== [{ts}][/bold yellow]{profile_disp}"
A.BOLD, A.FG_YELLOW, "<<<===== IN ====", A.FG_WHITE, profile_disp
)
) )
else: else:
self.disp( self.console.print(
A.color( f"[bold cyan]==== OUT ====>>> [{ts}][/bold cyan]{profile_disp}"
A.BOLD, A.FG_CYAN, "==== OUT ====>>>", A.FG_WHITE, profile_disp
)
) )
if whiteping: if whiteping:
self.disp("[WHITESPACE PING]") self.disp("[WHITESPACE PING]")
@ -177,9 +175,9 @@ class Monitor(base.CommandBase):
try: try:
await self.output(xml_data) await self.output(xml_data)
except Exception: except Exception:
#  initial stream is not valid XML, # initial stream is not valid XML,
# in this case we print directly to data # 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 # but importing lxml directly here is not clean
# should be wrapped in a custom Exception # should be wrapped in a custom Exception
self.disp(xml_data) self.disp(xml_data)