log-sidecar #

Generic stderr/stdin → Redis log fanout daemon. One script, any service.

What it does #

Tails a log source (a file via tail -F, or stdin), classifies each line into info / warn / error, and fans out to Redis per the protocol/redis-log-fanout v0.1 envelope:

Envelope shape:

{"v":0,"ts":1712534400000,"service":"llama-server","level":"info","msg":"ready"}

Usage #

scripts/log-sidecar --service llama-server --source /var/log/llama-server.err
scripts/log-sidecar --service dashboard    --source stdin < /dev/stdin
llama-server 2>&1 >/dev/null | scripts/log-sidecar --service llama-server --source stdin

Env vars #

VarDefaultMeaning
LOG_SIDECAR_DISABLED01 = drain source, publish nothing
REDIS_CLIredis-clioverride binary (e.g. redis-cli -n 1)
LOG_SIDECAR_STREAM_MAX10000stream MAXLEN ~ cap

Backpressure #

The tailer never blocks on Redis. Each publish forks a subshell with a timeout 1 around the redis-cli calls and is disowned. If Redis is down or slow, lines are silently dropped (no-op). This is the mpsc-style “prefer loss over stall” contract.

Level classification #

Simple case-insensitive regex on the raw line:

Subscriber example #

redis-cli psubscribe 'logs.llama-server.*'
redis-cli xlen  logs:stream:llama-server
redis-cli xrange logs:stream:llama-server - + COUNT 10

Acceptance checks #

echo "test" | scripts/log-sidecar --service foo --source stdin
redis-cli xlen logs:stream:foo        # >= 1
LOG_SIDECAR_DISABLED=1 echo hi | scripts/log-sidecar --service foo --source stdin
# no new entries