The source line (KMA, open-meteo or met.no for now; KMA and open-meteo day counts for a forecast) only went to debug_log, which is off by default and muted while the worker's brain answers, so a live answer such as "흐림" could not be traced to its service. It now goes to the llm log tab without the place or the key. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
48 lines
1.5 KiB
Python
48 lines
1.5 KiB
Python
"""Debug logging utilities for Jarvis."""
|
|
import sys
|
|
import time
|
|
from typing import Optional
|
|
from .config import load_settings
|
|
|
|
|
|
_last_check_time: float = 0.0
|
|
_cached_voice_debug: Optional[bool] = None
|
|
_CACHE_TTL_SECONDS: float = 2.0
|
|
|
|
|
|
def _is_debug_enabled() -> bool:
|
|
global _last_check_time, _cached_voice_debug
|
|
now = time.time()
|
|
if _cached_voice_debug is None or (now - _last_check_time) > _CACHE_TTL_SECONDS:
|
|
try:
|
|
_cached_voice_debug = bool(load_settings().voice_debug)
|
|
except Exception:
|
|
_cached_voice_debug = False
|
|
_last_check_time = now
|
|
return bool(_cached_voice_debug)
|
|
|
|
|
|
def debug_log(message: str, category: str = "debug") -> None:
|
|
"""Unified debug logging function for Jarvis.
|
|
|
|
Args:
|
|
message: The debug message to log
|
|
category: The log category (e.g., "debug", "voice", "echo", "tts", etc.)
|
|
"""
|
|
if not _is_debug_enabled():
|
|
return
|
|
try:
|
|
print(f"[{category:^10}] {message}", file=sys.stderr)
|
|
except Exception:
|
|
pass
|
|
|
|
|
|
def notice(message: str, category: str = "debug") -> None:
|
|
"""A line that is written also without debug logging, to the process's original stderr, so it
|
|
still reaches the app's log while the voice worker mutes the reply engine's output. It must carry
|
|
no question, answer, place or other text from the conversation."""
|
|
try:
|
|
print(f"[{category:^10}] {message}", file=sys.__stderr__, flush=True)
|
|
except Exception:
|
|
pass
|