feat(log): 优化唤醒和休眠日志的输出频率

对唤醒度和休眠检查的日志记录进行节流,以减少在消息密集时产生的日志数量。

- 在 `WakeUpManager` 中,唤醒度变化的日志现在每30秒最多输出一次 INFO 级别的日志,其余时间的日志降为 DEBUG 级别。
- 在 `ScheduleManager` 中,休眠期间被唤醒的日志也增加了类似的节流逻辑,以避免日志刷屏。
This commit is contained in:
tt-P607
2025-08-25 02:14:34 +08:00
parent 21aec70e92
commit 9adcc2e07d
2 changed files with 14 additions and 2 deletions

View File

@@ -418,7 +418,12 @@ class ScheduleManager:
if is_in_time_range:
# 检查是否被唤醒
if wakeup_manager and wakeup_manager.is_in_angry_state():
logger.info(f"在休眠活动 '{activity}' 期间,但已被唤醒。")
current_timestamp = datetime.now().timestamp()
if current_timestamp - self.last_sleep_log_time > self.sleep_log_interval:
logger.info(f"在休眠活动 '{activity}' 期间,但已被唤醒。")
self.last_sleep_log_time = current_timestamp
else:
logger.debug(f"在休眠活动 '{activity}' 期间,但已被唤醒。")
return False
current_timestamp = datetime.now().timestamp()