summaryrefslogtreecommitdiff
path: root/filters/terraria.py
blob: 93b5d9150f1fd0f69dc4d15367cc0ce7ba64221e (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
#!/usr/bin/env python3
"""
Terraria log filter for Umbrella (vanilla, tModLoader)

Vanilla and tModLoader produce fairly clean output, so this filter
mostly just strips blank lines and tModLoader's internal loading/debug
noise during startup.

Vanilla format:  plain text, e.g. ": <Player> has joined."
tModLoader format varies; startup emits many mod loading lines.

Install: /usr/lib/umbrella/filters/terraria.py
Unit YAML: log_filter: /usr/lib/umbrella/filters/terraria.py
"""

import sys
import re

SKIP = re.compile(
    r'^\s*$'                         # blank lines
    r'|^: $'                         # bare colon lines (vanilla idle)
    r'|\[tML\].*Loading mod'         # tModLoader mod loading spam
    r'|\[tML\].*Unloading mod'
    r'|\[tML\].*Reloading mods'
    r'|Received mods from'           # mod sync noise in multiplayer
    r'|Joining world\.\.\.'
)

for line in sys.stdin:
    if SKIP.search(line):
        continue
    sys.stdout.write(line)
    sys.stdout.flush()