summaryrefslogtreecommitdiff
path: root/src/umbrella.h
diff options
context:
space:
mode:
authorauric <auric@japegames.com>2026-02-22 19:13:06 -0600
committerauric <auric@japegames.com>2026-02-22 19:13:06 -0600
commit23527346905a2728c418170a155d0c24b10f5b25 (patch)
tree5edac5323122cf42b9a1ba5de83e58143b01fe4e /src/umbrella.h
parentf0baf8f2f3778d21692d377d32bd4e372cef2aae (diff)
Add log_filter: pluggable per-unit output filter subprocess
Each unit can specify log_filter: <path> 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 <noreply@anthropic.com>
Diffstat (limited to 'src/umbrella.h')
-rw-r--r--src/umbrella.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/umbrella.h b/src/umbrella.h
index 2e9d440..ff1873f 100644
--- a/src/umbrella.h
+++ b/src/umbrella.h
@@ -91,12 +91,19 @@ typedef struct {
Action actions[MAX_ACTIONS];
int action_count;
+ char log_filter[MAX_PATH]; /* path to filter executable, or empty */
+
/* Runtime state (populated by process/rcon layer, not yaml) */
ProcessState state;
pid_t pid; /* only for CONSOLE_STDIN */
int stdin_fd; /* only for CONSOLE_STDIN */
int stdout_fd; /* only for CONSOLE_STDIN */
RingBuffer *output;
+
+ /* Log filter subprocess (populated at runtime if log_filter is set) */
+ pid_t filter_pid;
+ int filter_in_fd; /* write end: daemon → filter stdin */
+ int filter_out_fd; /* read end: filter stdout → daemon */
} Unit;
/* ── Client: a connected socket client ───────────────────────────────────── */