Files
BT411/scratchpad/night6/digest3.py
T

74 lines
3.2 KiB
Python

"""Full-night digester, v3: PRIORITY tiers so the events that matter are never elided.
v2's flat cap kept 75 head + 75 tail lines per session -- which is all boot
chatter and all end-of-match chatter, eliding the actual combat in the middle.
v3 keeps every priority event (death/respawn/damage/warning/crash) unconditionally
and caps only the low-value context lines.
"""
import os
import re
DIR = os.path.dirname(os.path.abspath(__file__))
FILES = {
"full_sauron_XIAOLONG.log": "SAURON (XIAOLONG) -- hosted matches",
"full_elengil_ALIA.log": "Elengil (ALIA) -- desync + limp-skate reporter",
"full_rajel_GAMERSLAB.log": "RajelAran (GAMERSLAB) -- voice-replay reporter",
"full_connman_MSFIREFLY.log": "Conn Man (MS-FIREFLY)",
"roll_sauron_XIAOLONG.log": "SAURON rollover (late matches)",
"roll_rajel_GAMERSLAB.log": "RajelAran rollover (late matches)",
}
# Tier 1 -- NEVER elided.
PRIO = re.compile(
r"\[respawn\]|\[damage\]|\[deathfx\]|DESTROYED|SWALLOWED|RECOVERED|PLAYER_LINK"
r"|\[matchlog\]|KILL|DEATH|WARNING|ERROR|Fail\(|assert|crash|EXCEPTION"
r"|BUG \(Gitea|acquireFails|pool exhaust|\[gimp|\[crit|critroll"
r"|MakeMessage|DynamicEntity|CollisionVolume|collision volume", re.I)
# Tier 2 -- context, capped.
CTX = re.compile(r"\[steamnet\]|PEER_|ROUTE_|HELLO|LOBBY|\[exp\]|\[tick\]|\[paint\]", re.I)
MISSION = re.compile(r"\[respawn\]|DESTROYED|\[tick\]|\[exp\]", re.I)
CTX_CAP = 14
def run():
total = 0
for f, who in FILES.items():
p = os.path.join(DIR, f)
if not os.path.exists(p):
continue
raw = open(p, encoding="latin-1", errors="replace").read().splitlines()
b = [i for i, l in enumerate(raw) if "BT411 SESSION build=" in l] or [0]
b.append(len(raw))
out = [f"##### {who} ({f}, {len(raw)} lines, {len(b)-1} sessions)"]
for idx, (s, e) in enumerate(zip(b, b[1:])):
block = raw[s:e]
head = block[0][:140] if block else ""
build = (re.search(r"build=([0-9.]+)", head) or [None, "?"])[1]
local = (re.search(r"local=([0-9: -]+)", head) or [None, "?"])[1].strip()
if not any(MISSION.search(l) for l in block):
out.append(f"-- session {idx+1}: build={build} local={local} "
f"[{e-s} lines, no mission]")
continue
prio, ctx = [], []
for i, l in enumerate(block):
if PRIO.search(l):
prio.append(f" {s+i+1}: {l[:185]}")
elif CTX.search(l) and len(ctx) < CTX_CAP:
ctx.append(f" {s+i+1}: {l[:150]}")
out.append("")
out.append(f"===== session {idx+1}/{len(b)-1} build={build} local={local} "
f"raw {s+1}-{e} ({len(prio)} events)")
out.extend(ctx)
out.extend(prio)
d = "\n".join(out)
o = os.path.join(DIR, "d3_" + f.replace(".log", ".txt"))
open(o, "w", encoding="utf-8").write(d)
total += len(d)
print("%-30s -> %6.1f KB (%d sessions, %d priority events)" % (
f, len(d)/1024, d.count("===== session"),
sum(1 for l in d.splitlines() if PRIO.search(l))))
print("total: %.1f KB" % (total/1024))
run()