mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-08-19 03:28:28 -04:00
feat(gui): Display logs of specific swap on press of button on history page
This commit is contained in:
parent
063f9dbf9b
commit
c486ca5de9
5 changed files with 66 additions and 13 deletions
|
@ -18,3 +18,26 @@ export interface CliLog {
|
|||
[index: string]: unknown;
|
||||
}[];
|
||||
}
|
||||
|
||||
function isCliLog(log: unknown): log is CliLog {
|
||||
return (
|
||||
typeof log === "object" &&
|
||||
log !== null &&
|
||||
"timestamp" in log &&
|
||||
"level" in log &&
|
||||
"fields" in log
|
||||
);
|
||||
}
|
||||
|
||||
export function parseCliLogString(log: string): CliLog | string {
|
||||
try {
|
||||
const parsed = JSON.parse(log);
|
||||
if (isCliLog(parsed)) {
|
||||
return parsed;
|
||||
} else {
|
||||
return log;
|
||||
}
|
||||
} catch (err) {
|
||||
return log;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue