From bc5bb5be3975825b01122e66747246b791e8c2d3 Mon Sep 17 00:00:00 2001 From: muzam1l Date: Fri, 4 Mar 2022 15:22:05 +0530 Subject: [PATCH] Fix timesatmp in logs --- components/DebugStream.tsx | 4 ++-- components/LogBox.tsx | 4 ++-- state/index.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/components/DebugStream.tsx b/components/DebugStream.tsx index 639ba18..f39d166 100644 --- a/components/DebugStream.tsx +++ b/components/DebugStream.tsx @@ -31,10 +31,10 @@ const DebugStream = () => { if (typeof str !== "string") throw Error("Unrecognized debug log stream!"); const match = str.match(/([\s\S]+(?:UTC|ISO|GMT[+|-]\d+))\ ?([\s\S]*)/m); - const [_, time, msg] = match || []; + const [_, tm, msg] = match || []; const extracted = extractJSON(msg); - const timestamp = time ? new Date(time) : undefined; + const timestamp = isNaN(Date.parse(tm || '') ) ? tm : new Date(tm).toLocaleTimeString(); const message = !extracted ? msg : msg.slice(0, extracted.start) + msg.slice(extracted.end + 1); diff --git a/components/LogBox.tsx b/components/LogBox.tsx index 138ddd2..85f82ba 100644 --- a/components/LogBox.tsx +++ b/components/LogBox.tsx @@ -132,7 +132,7 @@ const LogBox: FC = ({ title, clearLog, logs, children, renderNav, enhan export const Log: FC = ({ type, - timestamp, + timestamp: timestamp, message: _message, link, linkText, @@ -181,7 +181,7 @@ export const Log: FC = ({ activeAccountAddress={dialogAccount} /> - {timestamp && {timestamp.toLocaleTimeString()} } + {timestamp && {timestamp} }
{message} 
{link && ( diff --git a/state/index.ts b/state/index.ts index 8d6e18e..d9a91f4 100644 --- a/state/index.ts +++ b/state/index.ts @@ -34,7 +34,7 @@ export interface ILog { type: "error" | "warning" | "log" | "success"; message: string; jsonData?: any, - timestamp?: Date; + timestamp?: string; link?: string; linkText?: string; defaultCollapsed?: boolean