This commit is contained in:
2026-02-06 23:34:20 -08:00
parent d806ebad85
commit af54acda3c
5 changed files with 498 additions and 392 deletions

View File

@@ -2068,13 +2068,13 @@ def _run(result: Any, args: Sequence[str], config: Dict[str, Any]) -> int:
"If you need full [main2] logs, restart mpv so it starts with --log-file."
)
# Print database logs for mpv module (helper output)
# Print database logs for mpv module (helper + lua output)
try:
import sqlite3
log_db_path = str((Path(__file__).resolve().parent.parent / "logs.db"))
conn = sqlite3.connect(log_db_path, timeout=5.0)
cur = conn.cursor()
query = "SELECT level, module, message FROM logs WHERE module = 'mpv'"
query = "SELECT timestamp, level, module, message FROM logs WHERE module = 'mpv'"
params: List[str] = []
if log_filter_text:
query += " AND LOWER(message) LIKE ?"
@@ -2085,57 +2085,24 @@ def _run(result: Any, args: Sequence[str], config: Dict[str, Any]) -> int:
cur.close()
conn.close()
if log_filter_text:
print(f"Helper logs from database (mpv module, filtered by '{log_filter_text}', most recent first):")
print(f"MPV logs from database (mpv module, filtered by '{log_filter_text}', most recent first):")
else:
print("Helper logs from database (mpv module, most recent first):")
print("MPV logs from database (mpv module, most recent first):")
if mpv_logs:
for level, module, message in mpv_logs:
print(f"[{level}] {message}")
for timestamp, level, module, message in mpv_logs:
ts = str(timestamp or "").strip()
if ts:
print(f"[{ts}] [{level}] {message}")
else:
print(f"[{level}] {message}")
else:
if log_filter_text:
print(f"(no helper logs found matching '{log_filter_text}')")
print(f"(no mpv logs found matching '{log_filter_text}')")
else:
print("(no helper logs found)")
print("(no mpv logs found)")
except Exception as e:
debug(f"Could not fetch database logs: {e}")
pass
# Also print the helper log tail (this captures Python helper output that won't
# necessarily show up in MPV's own log-file).
try:
helper_path = _helper_log_file()
helper_tail = _tail_text_file(str(helper_path), max_lines=200)
filtered_helper = _apply_log_filter(helper_tail, log_filter_text)
print(f"Helper log file: {str(helper_path)}")
if filtered_helper:
print("Helper log (tail):")
for ln in filtered_helper:
print(ln)
else:
if log_filter_text:
print(f"(no helper file logs found matching '{log_filter_text}')")
else:
print("Helper log (tail): <empty>")
except Exception:
pass
# Also print the Lua-side log tail (mp.msg output isn't always written to mpv's log-file).
try:
lua_path = _lua_log_file()
lua_tail = _tail_text_file(str(lua_path), max_lines=200)
filtered_lua = _apply_log_filter(lua_tail, log_filter_text)
print(f"Lua log file: {str(lua_path)}")
if filtered_lua:
print("Lua log (tail):")
for ln in filtered_lua:
print(ln)
else:
if log_filter_text:
print(f"(no lua file logs found matching '{log_filter_text}')")
else:
print("Lua log (tail): <empty>")
except Exception:
pass
except Exception:
pass
try: