diff options
Diffstat (limited to 'web/pw-server/src')
-rw-r--r-- | web/pw-server/src/lib/components/OutputPane.svelte | 38 | ||||
-rw-r--r-- | web/pw-server/src/lib/components/log_viewer/LogTurn.svelte | 0 |
2 files changed, 14 insertions, 24 deletions
diff --git a/web/pw-server/src/lib/components/OutputPane.svelte b/web/pw-server/src/lib/components/OutputPane.svelte index 4123902..759fd4c 100644 --- a/web/pw-server/src/lib/components/OutputPane.svelte +++ b/web/pw-server/src/lib/components/OutputPane.svelte @@ -1,34 +1,21 @@ <script lang="ts"> - export let matchLog: string; + import { parsePlayerLog, PlayerLog } from "$lib/log_parser"; - function getStdErr(botId: number, log?: string): string { - if (!log) { - return ""; - } + export let matchLog: string; + let playerLog: PlayerLog; - let output = []; - log - .split("\n") - .slice(0, -1) - .forEach((line) => { - let message = JSON.parse(line); - if (message["type"] === "stderr" && message["player_id"] === botId) { - output.push(message["message"]); - } - }); - return output.join("\n"); + $: if (matchLog) { + playerLog = parsePlayerLog(1, matchLog); + } else { + playerLog = []; } - - $: botStdErr = getStdErr(1, matchLog); </script> <div class="output"> - {#if botStdErr.length > 0} - <h3 class="output-header">stderr:</h3> - <div class="output-text"> - {botStdErr} - </div> - {/if} + <h3 class="output-header">Player log</h3> + <div class="output-text stderr-text"> + {playerLog.flatMap((turn) => turn.stderr).join("\n")} + </div> </div> <style lang="scss"> @@ -41,6 +28,9 @@ .output-text { color: #ccc; + } + + .stderr-text { font-family: monospace; white-space: pre-wrap; } diff --git a/web/pw-server/src/lib/components/log_viewer/LogTurn.svelte b/web/pw-server/src/lib/components/log_viewer/LogTurn.svelte new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/web/pw-server/src/lib/components/log_viewer/LogTurn.svelte |