feat: push_gate 判定分支加结构化日志

force/推送/静默日/无更新仍推 四分支各记一条 logger.info,
无人值守时可定位「早报没推是静默日还是别的原因」(T7)。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-18 16:55:47 +08:00
parent 3321a307a0
commit d7992e7a7a

View File

@@ -2,11 +2,14 @@
from __future__ import annotations
import logging
from dataclasses import dataclass, field
from typing import Any
from daily.config import force_push, skip_push_when_silent
logger = logging.getLogger(__name__)
@dataclass
class PushGateResult:
@@ -34,6 +37,7 @@ def evaluate_push_gate(
featured_pick: dict[str, Any] | None,
) -> PushGateResult:
if force_push():
logger.info("push_gate: force_push=on, 强制推送")
return PushGateResult(should_push=True, reasons=["force_push"], silent=False)
reasons: list[str] = []
@@ -48,4 +52,10 @@ def evaluate_push_gate(
should = bool(reasons)
silent = not should and skip_push_when_silent()
if should:
logger.info("push_gate: 推送 (原因: %s)", ",".join(reasons))
elif silent:
logger.info("push_gate: 静默日, 跳过推送 (无任何更新信号)")
else:
logger.info("push_gate: 无更新但 skip_push_when_silent=off, 仍推送")
return PushGateResult(should_push=should, reasons=reasons, silent=silent)