summaryrefslogtreecommitdiff
path: root/filters/source.py
blob: a42e185c63916e613594f318d5e0ab4c67be6adc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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()