diff options
author | Ilion Beyst <ilion.beyst@gmail.com> | 2022-02-23 22:30:36 +0100 |
---|---|---|
committer | Ilion Beyst <ilion.beyst@gmail.com> | 2022-02-23 22:30:36 +0100 |
commit | 816b3bfc277dbdde0716fcd8946bb13440d67767 (patch) | |
tree | b0ed21200026ac3d57c9436dc5837af9ead13b27 /web/pw-server/src/lib/components/OutputPane.svelte | |
parent | 54b9694f0d0d7e853592317d60ad262ae8c13568 (diff) | |
download | planetwars.dev-816b3bfc277dbdde0716fcd8946bb13440d67767.tar.xz planetwars.dev-816b3bfc277dbdde0716fcd8946bb13440d67767.zip |
show bot stderr
Diffstat (limited to 'web/pw-server/src/lib/components/OutputPane.svelte')
-rw-r--r-- | web/pw-server/src/lib/components/OutputPane.svelte | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/web/pw-server/src/lib/components/OutputPane.svelte b/web/pw-server/src/lib/components/OutputPane.svelte new file mode 100644 index 0000000..c72a22e --- /dev/null +++ b/web/pw-server/src/lib/components/OutputPane.svelte @@ -0,0 +1,48 @@ +<script lang="ts"> + export let matchLog: string; + + function getStdErr(log: string, botId: number): string { + 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"); + } + + $: botStdErr = getStdErr(matchLog, 1); +</script> + +<div class="output"> + {#if botStdErr.length > 0} + <h3 class="output-header">stderr:</h3> + <div class="output-text"> + {botStdErr} + </div> + {/if} +</div> + +<style lang="scss"> + .output { + width: 100%; + overflow-y: scroll; + background-color: rgb(41, 41, 41); + padding: 15px; + } + + .output-text { + color: #ccc; + font-family: monospace; + white-space: pre-wrap; + } + + .output-header { + color: #eee; + padding-bottom: 20px; + } +</style> |