cli (debug/monitor): Add timestamp to XML logs.
This commit is contained in:
parent
dc9e3e98d5
commit
a3cc29ca3c
1 changed files with 9 additions and 11 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue