diff --git a/alert_logger.py b/alert_logger.py index 8aa796e9..0eea529b 100644 --- a/alert_logger.py +++ b/alert_logger.py @@ -68,6 +68,23 @@ def record_alert(level="error", source="", title="", detail="", code="", clear_a except Exception: pass + # 2.5 写入 broadcast_messages 表(统一消息源,异常=system_error类) + try: + from messenger import _classify, DB + import sqlite3 as _sq3 + _cat = _classify(title, detail) + # 异常/告警统一归为 system_error 类(供右上角异常浮窗筛选) + if level in ("error", "critical", "warning"): + _cat = "system_error" + _conn = _sq3.connect(DB, timeout=30) + _conn.execute( + "INSERT INTO broadcast_messages (ts, category, title, content, source) VALUES (?,?,?,?,?)", + (ts_str, _cat, title, detail, source)) + _conn.commit() + _conn.close() + except Exception: + pass + # 3. XMPP 告警(非 info 级别才发,避免轰炸)→ 本地 XMPP 发送服务 :5805 if level != "info": try: