summaryrefslogtreecommitdiff
path: root/filters/minecraft.py
diff options
context:
space:
mode:
Diffstat (limited to 'filters/minecraft.py')
-rw-r--r--filters/minecraft.py45
1 files changed, 45 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()