From 1b177df525e83b352146f7847d09f7309ef3d7b7 Mon Sep 17 00:00:00 2001 From: HUAHUAI23 Date: Wed, 24 Jul 2024 09:05:53 +0000 Subject: [PATCH] lastest --- .../app/mods/StatusBar/LogsModal/index.tsx | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/web/src/pages/app/mods/StatusBar/LogsModal/index.tsx b/web/src/pages/app/mods/StatusBar/LogsModal/index.tsx index 8b411bd..74db0a6 100644 --- a/web/src/pages/app/mods/StatusBar/LogsModal/index.tsx +++ b/web/src/pages/app/mods/StatusBar/LogsModal/index.tsx @@ -38,6 +38,21 @@ type Log = { const MAX_RETRIES = 5; +const timestampRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z/; + +function convertLogTimestamp(log: Log): Log { + const match = log.data.match(timestampRegex); + + if (match) { + const timestamp = match[0]; + const date = new Date(timestamp); + const clientTimeString = date.toString(); + log.data = log.data.replace(timestamp, clientTimeString); + } + + return log; +} + export default function LogsModal(props: { children: React.ReactElement }) { const { children } = props; const { isOpen, onOpen, onClose } = useDisclosure(); @@ -128,13 +143,14 @@ export default function LogsModal(props: { children: React.ReactElement }) { } }, - onmessage(msg) { + onmessage(msg: Log) { if (msg.event === "error") { showWarning(msg.data); } if (msg.event === "log") { - addOrUpdateLog(msg); + const log: Log = convertLogTimestamp(msg); + addOrUpdateLog(log); retryCountRef.current = 0; } },