From 816b3bfc277dbdde0716fcd8946bb13440d67767 Mon Sep 17 00:00:00 2001
From: Ilion Beyst <ilion.beyst@gmail.com>
Date: Wed, 23 Feb 2022 22:30:36 +0100
Subject: show bot stderr

---
 web/pw-server/src/lib/components/OutputPane.svelte | 48 ++++++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100644 web/pw-server/src/lib/components/OutputPane.svelte

(limited to 'web/pw-server/src/lib/components/OutputPane.svelte')

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>
-- 
cgit v1.2.3

