This commit is contained in:
2026-03-25 00:56:58 -07:00
parent 96f327e4dc
commit c31402c8f1
5 changed files with 89 additions and 12 deletions

View File

@@ -256,18 +256,41 @@ def _focus_db_log_rows(
return _collapse_repeated_log_lines(rendered)
def _slice_mpv_log_to_latest_run(lines: Sequence[str]) -> List[str]:
startup_pattern = re.compile(r"\bmpv v\d", re.IGNORECASE)
def _slice_log_to_latest_marker(
lines: Sequence[str],
patterns: Sequence[re.Pattern[str]],
) -> List[str]:
collected = list(lines)
if not collected:
return []
for idx in range(len(collected) - 1, -1, -1):
text = str(collected[idx] or "")
if startup_pattern.search(text):
if any(pattern.search(text) for pattern in patterns):
return collected[idx:]
return collected
def _slice_mpv_log_to_latest_run(lines: Sequence[str]) -> List[str]:
return _slice_log_to_latest_marker(
lines,
[re.compile(r"\bmpv v\d", re.IGNORECASE)],
)
def _slice_lua_log_to_latest_run(lines: Sequence[str]) -> List[str]:
return _slice_log_to_latest_marker(
lines,
[re.compile(r"medeia[- ]lua loaded version=", re.IGNORECASE)],
)
def _slice_helper_log_to_latest_run(lines: Sequence[str]) -> List[str]:
return _slice_log_to_latest_marker(
lines,
[re.compile(r"\[helper\] version=.* started ipc=", re.IGNORECASE)],
)
def _get_mpv_property(prop_name: str) -> Optional[Any]:
try:
resp = _send_ipc_command(
@@ -2456,8 +2479,22 @@ def _run(result: Any, args: Sequence[str], config: Dict[str, Any]) -> int:
else:
print("MPV core log: <no focused entries>")
try:
lua_tail = _tail_text_file(str(_lua_log_file()), max_lines=400, max_bytes=262144)
except Exception:
lua_tail = []
lua_tail = _slice_lua_log_to_latest_run(lua_tail)
lua_tail = _collapse_repeated_log_lines(_apply_log_filter(lua_tail, log_filter_text))
if lua_tail:
title = "Medeia Lua log (latest run)"
if log_filter_text:
title += f" filtered by '{log_filter_text}'"
title += ":"
print(title)
for line in lua_tail:
print(line)
fallback_logs = [
("Medeia Lua log file tail", str(_lua_log_file())),
("Medeia helper log file tail", str(_helper_log_file())),
]
for title, path in fallback_logs:
@@ -2465,6 +2502,8 @@ def _run(result: Any, args: Sequence[str], config: Dict[str, Any]) -> int:
lines = _tail_text_file(path, max_lines=120)
except Exception:
lines = []
if path == str(_helper_log_file()):
lines = _slice_helper_log_to_latest_run(lines)
lines = _collapse_repeated_log_lines(_apply_log_filter(lines, log_filter_text))
if not lines:
continue