about summary refs log tree commit diff stats
path: root/archive/2024/winter/bsc_dichler/scripts/log.py
diff options
context:
space:
mode:
Diffstat (limited to 'archive/2024/winter/bsc_dichler/scripts/log.py')
-rw-r--r--archive/2024/winter/bsc_dichler/scripts/log.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/archive/2024/winter/bsc_dichler/scripts/log.py b/archive/2024/winter/bsc_dichler/scripts/log.py
new file mode 100644
index 000000000..0bb7fb438
--- /dev/null
+++ b/archive/2024/winter/bsc_dichler/scripts/log.py
@@ -0,0 +1,20 @@
+def log(prefix: str, msg: str, intend: int = 0):
+    intend_offset = "\t" * intend
+    for line in msg.split("\n"):
+        if len(line) == 0:
+            continue
+        line = prefix + intend_offset + msg
+        print(line, flush=True)
+
+
+def info(msg: str, intend: int = 1):
+    intend = intend + 1
+    GREEN = "\033[32m"
+    RESET = "\033[0m\033[39m"
+    log(prefix=GREEN + "stdout>" + RESET, msg=msg, intend=intend)
+
+
+def error(msg: str):
+    RED = "\033[31m"
+    RESET = "\033[0m\033[39m"
+    log(prefix=RED + "stderr>" + RESET, msg=msg, intend=1)