test
This commit is contained in:
@@ -5,7 +5,7 @@ import sys
|
||||
import json
|
||||
import socket
|
||||
import re
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timedelta
|
||||
from urllib.parse import urlparse, parse_qs
|
||||
from pathlib import Path
|
||||
from SYS.cmdlet_spec import Cmdlet, CmdletArg, parse_cmdlet_args
|
||||
@@ -2086,6 +2086,9 @@ def _run(result: Any, args: Sequence[str], config: Dict[str, Any]) -> int:
|
||||
cur = conn.cursor()
|
||||
query = "SELECT timestamp, level, module, message FROM logs WHERE module = 'mpv'"
|
||||
params: List[str] = []
|
||||
cutoff_24h = (datetime.utcnow() - timedelta(hours=24)).strftime("%Y-%m-%d %H:%M:%S")
|
||||
query += " AND timestamp >= ?"
|
||||
params.append(cutoff_24h)
|
||||
if log_filter_text:
|
||||
query += " AND LOWER(message) LIKE ?"
|
||||
params.append(f"%{log_filter_text.lower()}%")
|
||||
@@ -2095,9 +2098,11 @@ def _run(result: Any, args: Sequence[str], config: Dict[str, Any]) -> int:
|
||||
cur.close()
|
||||
conn.close()
|
||||
if log_filter_text:
|
||||
print(f"MPV logs from database (mpv module, filtered by '{log_filter_text}', most recent first):")
|
||||
print(
|
||||
f"MPV logs from database (mpv module, last 24h, filtered by '{log_filter_text}', most recent first):"
|
||||
)
|
||||
else:
|
||||
print("MPV logs from database (mpv module, most recent first):")
|
||||
print("MPV logs from database (mpv module, last 24h, most recent first):")
|
||||
if mpv_logs:
|
||||
for timestamp, level, _module, message in mpv_logs:
|
||||
ts = str(timestamp or "").strip()
|
||||
@@ -2305,7 +2310,7 @@ CMDLET = Cmdlet(
|
||||
CmdletArg(
|
||||
name="log",
|
||||
type="flag",
|
||||
description="Enable pipeable debug output, write an mpv log file, and optionally specify a filter string right after -log to search the stored logs",
|
||||
description="Enable pipeable debug output, write an mpv log file, and optionally specify a filter string right after -log to search stored mpv logs from the last 24 hours",
|
||||
),
|
||||
CmdletArg(
|
||||
name="borderless",
|
||||
|
||||
Reference in New Issue
Block a user