summaryrefslogtreecommitdiff
path: root/filters
diff options
context:
space:
mode:
Diffstat (limited to 'filters')
-rw-r--r--filters/minecraft.py45
-rw-r--r--filters/source.py35
-rw-r--r--filters/terraria.py33
3 files changed, 113 insertions, 0 deletions
diff --git a/filters/minecraft.py b/filters/minecraft.py
new file mode 100644
index 0000000..d4112d6
--- /dev/null
+++ b/filters/minecraft.py
@@ -0,0 +1,45 @@
+#!/usr/bin/env python3
+"""
+Minecraft log filter for Umbrella (vanilla, Paper, Spigot, Fabric, etc.)
+
+Strips low-value noise:
+ - keepAlive packet spam (Paper/Spigot debug logs)
+ - Internal class/library log lines
+ - Advancement grant/revoke noise
+ - Saving chunks / autosave lines
+ - UUID cache loading lines
+
+Strips the "[HH:MM:SS] [Thread/LEVEL]: " prefix from standard Minecraft
+log format, since the daemon already timestamps output.
+
+Install: /usr/lib/umbrella/filters/minecraft.py
+Unit YAML: log_filter: /usr/lib/umbrella/filters/minecraft.py
+"""
+
+import sys
+import re
+
+# Standard Minecraft log prefix: [HH:MM:SS] [Server thread/INFO]:
+PREFIX = re.compile(r'^\[\d{2}:\d{2}:\d{2}\] \[[^\]]+\]: ')
+
+SKIP = re.compile(
+ r'keepAlive' # packet keepAlive debug
+ r'|Saving chunks for level' # periodic autosave
+ r'|Saving and pausing game'
+ r'|com\.mojang\.' # internal Mojang class logs
+ r'|RCON Client /' # RCON connection noise
+ r'|RCON Listener'
+ r'|Preparing spawn area'
+ r'|Loading libraries'
+ r'|Loaded \d+ recipes'
+ r'|Loaded \d+ advancements'
+ r'|\[uuid-cache\]'
+ r'|^\s*$'
+)
+
+for line in sys.stdin:
+ if SKIP.search(line):
+ continue
+ line = PREFIX.sub('', line)
+ sys.stdout.write(line)
+ sys.stdout.flush()
diff --git a/filters/source.py b/filters/source.py
new file mode 100644
index 0000000..a42e185
--- /dev/null
+++ b/filters/source.py
@@ -0,0 +1,35 @@
+#!/usr/bin/env python3
+"""
+Source engine log filter for Umbrella (TF2, GMod, CS2, etc.)
+
+Strips noisy lines that flood the output without useful information:
+ - server_cvar changes (spammy on startup and plugin reloads)
+ - Bot navigation stuck/path_goal spam
+ - Empty lines
+
+Strips the "L MM/DD/YYYY - HH:MM:SS: " timestamp prefix so output
+is shorter in the CLI. The umbrella daemon log already has its own
+timestamps if you need them.
+
+Install: /usr/lib/umbrella/filters/source.py
+Unit YAML: log_filter: /usr/lib/umbrella/filters/source.py
+"""
+
+import sys
+import re
+
+PREFIX = re.compile(r'^L \d{2}/\d{2}/\d{4} - \d{2}:\d{2}:\d{2}: ')
+
+SKIP = re.compile(
+ r'server_cvar:' # cvar change spam
+ r'|" stuck \(position' # bot navigation noise
+ r'|^\s*path_goal \(' # bot path_goal continuation lines
+ r'|^\s*$' # blank lines
+)
+
+for line in sys.stdin:
+ if SKIP.search(line):
+ continue
+ line = PREFIX.sub('', line)
+ sys.stdout.write(line)
+ sys.stdout.flush()
diff --git a/filters/terraria.py b/filters/terraria.py
new file mode 100644
index 0000000..93b5d91
--- /dev/null
+++ b/filters/terraria.py
@@ -0,0 +1,33 @@
+#!/usr/bin/env python3
+"""
+Terraria log filter for Umbrella (vanilla, tModLoader)
+
+Vanilla and tModLoader produce fairly clean output, so this filter
+mostly just strips blank lines and tModLoader's internal loading/debug
+noise during startup.
+
+Vanilla format: plain text, e.g. ": <Player> has joined."
+tModLoader format varies; startup emits many mod loading lines.
+
+Install: /usr/lib/umbrella/filters/terraria.py
+Unit YAML: log_filter: /usr/lib/umbrella/filters/terraria.py
+"""
+
+import sys
+import re
+
+SKIP = re.compile(
+ r'^\s*$' # blank lines
+ r'|^: $' # bare colon lines (vanilla idle)
+ r'|\[tML\].*Loading mod' # tModLoader mod loading spam
+ r'|\[tML\].*Unloading mod'
+ r'|\[tML\].*Reloading mods'
+ r'|Received mods from' # mod sync noise in multiplayer
+ r'|Joining world\.\.\.'
+)
+
+for line in sys.stdin:
+ if SKIP.search(line):
+ continue
+ sys.stdout.write(line)
+ sys.stdout.flush()