From f5fe1c4f2918561d70a56d196aaf1b13c97a2bf1 Mon Sep 17 00:00:00 2001 From: Ilion Beyst Date: Sat, 17 Sep 2022 11:55:17 +0200 Subject: initial version of structured log display --- web/pw-server/src/lib/components/OutputPane.svelte | 80 +++++++++++++++++++++- web/pw-server/src/lib/log_parser.ts | 55 +++++++++++++++ 2 files changed, 134 insertions(+), 1 deletion(-) create mode 100644 web/pw-server/src/lib/log_parser.ts (limited to 'web/pw-server/src/lib') diff --git a/web/pw-server/src/lib/components/OutputPane.svelte b/web/pw-server/src/lib/components/OutputPane.svelte index 759fd4c..efd0d2c 100644 --- a/web/pw-server/src/lib/components/OutputPane.svelte +++ b/web/pw-server/src/lib/components/OutputPane.svelte @@ -4,6 +4,8 @@ export let matchLog: string; let playerLog: PlayerLog; + let showRawStderr = false; + $: if (matchLog) { playerLog = parsePlayerLog(1, matchLog); } else { @@ -13,9 +15,38 @@

Player log

+ {#if showRawStderr}
{playerLog.flatMap((turn) => turn.stderr).join("\n")}
+ {:else} +
+ {#each playerLog as logTurn, i} +
+
+ Turn {i} + {#if logTurn.action?.type === "bad_command"} + invalid command + {/if} +
+ {#if logTurn.action?.type === "bad_command"} +
+
{logTurn.action.command}
+
Parse error: {logTurn.action.error}
+
+ {/if} + {#if logTurn.stderr.length > 0} +
stderr
+
+ {#each logTurn.stderr as stdErrMsg} +
{stdErrMsg}
+ {/each} +
+ {/if} +
+ {/each} +
+ {/if}