From 23527346905a2728c418170a155d0c24b10f5b25 Mon Sep 17 00:00:00 2001 From: auric Date: Sun, 22 Feb 2026 19:13:06 -0600 Subject: Add log_filter: pluggable per-unit output filter subprocess MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Each unit can specify log_filter: pointing to any executable that reads stdin and writes filtered output to stdout. The daemon spawns it once at startup (and on SIGHUP), pipes raw log data through it before ring-buffering and broadcasting to attached clients. filter.c handles spawn (fork/exec with pipes), per-chunk apply (write + poll with 250ms timeout, pass-through on silence/timeout), and stop (SIGTERM + fd cleanup). Filters are stopped and restarted cleanly on SIGHUP alongside log_tail. Bundled filters in filters/: source.py — TF2, GMod: strips server_cvar/stuck/path_goal spam, strips the L MM/DD/YYYY - HH:MM:SS: prefix minecraft.py — vanilla/Paper/Spigot: strips keepAlive, autosave, internal class logs, strips [HH:MM:SS] [thread] prefix terraria.py — vanilla/tModLoader: strips blank lines and mod loading noise during startup Any executable reading stdin/writing stdout works as a custom filter. Co-Authored-By: Claude Sonnet 4.6 --- filters/source.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 filters/source.py (limited to 'filters/source.py') 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() -- cgit v1.2.3