fix(app): log hub masks dotted tokens, keeps worker errors and drops the oldest lines by time
- redact: a token with sentence dots around it is masked too. - Worker error messages are always logged (code and id), so the log screen and the error report show them without debug logging. - The voice worker logs with stt, llm and tts categories, so its lines land in those tabs. - The zip leaves out the oldest lines by the time they were logged, across every tab's file, not by file name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -169,7 +169,7 @@ class JarvisBrain:
|
||||
self._memories: dict = {}
|
||||
self._prepared: dict[str, _Prepared] = {}
|
||||
self._lock = threading.Lock()
|
||||
debug_log(f"brain ready: llm={self.cfg.ollama_base_url} model={self.cfg.ollama_chat_model}", "voice_worker")
|
||||
debug_log(f"brain ready: llm={self.cfg.ollama_base_url} model={self.cfg.ollama_chat_model}", "llm")
|
||||
|
||||
def _memory(self, user: str):
|
||||
from jarvis.memory.conversation import DialogueMemory
|
||||
@@ -198,7 +198,7 @@ class JarvisBrain:
|
||||
finally:
|
||||
p.done.set()
|
||||
debug_log(f"brain prepare user={user} picked={p.tools is not None} "
|
||||
f"ms={(time.perf_counter() - t0) * 1000:.0f}", "voice_worker")
|
||||
f"ms={(time.perf_counter() - t0) * 1000:.0f}", "llm")
|
||||
|
||||
def _prepared_tools(self, user: str, text: str) -> Optional[list]:
|
||||
"""The pick prepared for about this text, waiting for one still being made; None if none fits."""
|
||||
@@ -233,7 +233,7 @@ class JarvisBrain:
|
||||
|
||||
answer = Muted.run(turn)
|
||||
debug_log(f"brain reply user={user} ok={bool(answer)} prepared={prepared is not None} "
|
||||
f"ms={(time.perf_counter() - t0) * 1000:.0f}", "voice_worker")
|
||||
f"ms={(time.perf_counter() - t0) * 1000:.0f}", "llm")
|
||||
return answer
|
||||
|
||||
def addressed(self, user: str, text: str, names: list[str]) -> Optional[bool]:
|
||||
|
||||
@@ -50,7 +50,7 @@ def is_addressed(base_url: str, model: str, names: Sequence[str], text: str,
|
||||
word = (raw or "").strip().lower().lstrip("\"'*").split()
|
||||
answer = word[0].rstrip(".,!\"'*") if word else ""
|
||||
result = True if answer == "yes" else False if answer == "no" else None
|
||||
debug_log(f"judge addressed -> {result}", "voice_worker")
|
||||
debug_log(f"judge addressed -> {result}", "llm")
|
||||
return result
|
||||
|
||||
|
||||
@@ -67,8 +67,8 @@ def rank_requests(base_url: str, model: str, texts: Sequence[str],
|
||||
if 0 <= i < len(texts) and i not in order:
|
||||
order.append(i)
|
||||
if not order:
|
||||
debug_log(f"judge rank candidates={len(texts)} -> none", "voice_worker")
|
||||
debug_log(f"judge rank candidates={len(texts)} -> none", "llm")
|
||||
return None
|
||||
order += [i for i in range(len(texts)) if i not in order]
|
||||
debug_log(f"judge rank candidates={len(texts)} -> first={order[0] + 1}", "voice_worker")
|
||||
debug_log(f"judge rank candidates={len(texts)} -> first={order[0] + 1}", "llm")
|
||||
return order
|
||||
|
||||
@@ -120,9 +120,9 @@ class SttScheduler:
|
||||
texts, error = [""] * len(batch), f"{type(e).__name__}: {e}"
|
||||
ms = int((time.perf_counter() - t0) * 1000)
|
||||
debug_log(f"stt batch kind={kind} size={len(batch)} beam={batch[0].opts.beam} ms={ms}"
|
||||
+ (f" error={error}" if error else ""), "voice_worker")
|
||||
+ (f" error={error}" if error else ""), "stt")
|
||||
for job, text in zip(batch, texts):
|
||||
try:
|
||||
job.callback(SttResult(text, ms, error))
|
||||
except Exception as e: # pragma: no cover - a broken session must not stop the loop
|
||||
debug_log(f"stt callback failed: {type(e).__name__}: {e}", "voice_worker")
|
||||
debug_log(f"stt callback failed: {type(e).__name__}: {e}", "stt")
|
||||
|
||||
@@ -272,7 +272,7 @@ class Session:
|
||||
self._partial_cb(speaker, st, ev.utt))
|
||||
elif isinstance(ev, Final):
|
||||
debug_log(f"utterance end speaker={speaker} utt={ev.utt} reason={ev.reason} "
|
||||
f"ms={len(ev.audio) * 1000 // SR}", "voice_worker")
|
||||
f"ms={len(ev.audio) * 1000 // SR}", "stt")
|
||||
# Where, when and by whom it was said, fixed now: decoding can take a while, and a
|
||||
# move or a late joiner meanwhile must not change who heard it.
|
||||
said = (self.voice_channel, self.names.get(speaker, speaker),
|
||||
@@ -546,7 +546,7 @@ class Session:
|
||||
try:
|
||||
await asyncio.to_thread(self.worker.brain.prepare, user, text, bool(self.chat_channels))
|
||||
except Exception as e: # the brain must never take the session down
|
||||
debug_log(f"brain prepare failed: {type(e).__name__}", "voice_worker")
|
||||
debug_log(f"brain prepare failed: {type(e).__name__}", "llm")
|
||||
newer, self.preparing[user] = self.preparing[user], None
|
||||
text = newer if newer is not None and not similar(newer, self.last_prepared.get(user, "")) else None
|
||||
finally:
|
||||
@@ -565,9 +565,9 @@ class Session:
|
||||
try:
|
||||
yes = await asyncio.to_thread(self.worker.brain.addressed, user, text, list(self.settings.hotwords))
|
||||
except Exception as e: # the brain must never take the session down
|
||||
debug_log(f"brain addressed {qid} failed: {type(e).__name__}", "voice_worker")
|
||||
debug_log(f"brain addressed {qid} failed: {type(e).__name__}", "llm")
|
||||
yes = None
|
||||
debug_log(f"brain addressed {qid} -> {yes}", "voice_worker")
|
||||
debug_log(f"brain addressed {qid} -> {yes}", "llm")
|
||||
self.send({"type": "addressed_result", "id": qid, "addressed": bool(yes), "failed": yes is None})
|
||||
asyncio.get_running_loop().create_task(judge())
|
||||
|
||||
@@ -587,11 +587,11 @@ class Session:
|
||||
try:
|
||||
order = await asyncio.to_thread(self.worker.brain.rank, cands)
|
||||
except Exception as e:
|
||||
debug_log(f"brain rank {qid} failed: {type(e).__name__}", "voice_worker")
|
||||
debug_log(f"brain rank {qid} failed: {type(e).__name__}", "llm")
|
||||
order = None
|
||||
known = {c["id"] for c in cands}
|
||||
order = [i for i in (order or []) if i in known] if order is not None else None
|
||||
debug_log(f"brain rank {qid} candidates={len(cands)} ok={order is not None}", "voice_worker")
|
||||
debug_log(f"brain rank {qid} candidates={len(cands)} ok={order is not None}", "llm")
|
||||
self.send({"type": "rank_result", "id": qid, "order": order or [], "failed": order is None})
|
||||
asyncio.get_running_loop().create_task(rank())
|
||||
|
||||
@@ -622,7 +622,7 @@ class Session:
|
||||
# They never got this answer, so nothing it asked can be confirmed next.
|
||||
w = self.worker
|
||||
w.reply_turns[user] = max(w.reply_turns.get(user, 0), turn + 1)
|
||||
debug_log(f"brain reply {rid} did not reach the asker", "voice_worker")
|
||||
debug_log(f"brain reply {rid} did not reach the asker", "llm")
|
||||
self._reached(user)
|
||||
|
||||
def _on_reply_delivered(self, msg: dict) -> None:
|
||||
@@ -653,14 +653,14 @@ class Session:
|
||||
turn = w.reply_turns[user] = w.reply_turns.get(user, 0) + (2 if early else 1)
|
||||
if early:
|
||||
debug_log(f"brain reply {rid} arrived before the previous answer: a turn is skipped",
|
||||
"voice_worker")
|
||||
"llm")
|
||||
from .chat_bridge import ChatBridge
|
||||
chat = ChatBridge(self, asyncio.get_running_loop(), turn, w.pending_deletes.setdefault(user, {})) \
|
||||
if self.chat_channels else None
|
||||
try:
|
||||
answer = await asyncio.to_thread(w.brain.reply, user, text, history, chat=chat)
|
||||
except Exception as e: # the brain must never take the session down
|
||||
debug_log(f"brain reply {rid} failed: {type(e).__name__}", "voice_worker")
|
||||
debug_log(f"brain reply {rid} failed: {type(e).__name__}", "llm")
|
||||
answer = None
|
||||
answer = (answer or "").strip()
|
||||
self.send({"type": "reply_text", "id": rid, "text": answer, "failed": not answer})
|
||||
@@ -680,7 +680,7 @@ class Session:
|
||||
if via == "voice" and channel and w.history is not None:
|
||||
w.history.add_reply(channel, user, answer, time.time())
|
||||
if speak and rid in self.cancelled_replies:
|
||||
debug_log(f"brain reply {rid} not spoken: cancelled while answering", "voice_worker")
|
||||
debug_log(f"brain reply {rid} not spoken: cancelled while answering", "llm")
|
||||
self.send({"type": "tts_done", "id": rid, "chunks": 0, "cancelled": True, "failed": False})
|
||||
elif speak:
|
||||
self._on_tts({"type": "tts", "id": rid, "text": answer, "more": False})
|
||||
|
||||
@@ -90,7 +90,7 @@ class WhisperTranscriber:
|
||||
from faster_whisper import WhisperModel
|
||||
self.model = WhisperModel(model, device=device, compute_type=compute_type)
|
||||
self._tokenizers: dict = {}
|
||||
debug_log(f"whisper loaded model={model} device={device} compute={compute_type}", "voice_worker")
|
||||
debug_log(f"whisper loaded model={model} device={device} compute={compute_type}", "stt")
|
||||
|
||||
def _tokenizer(self, language: str):
|
||||
tok = self._tokenizers.get(language)
|
||||
|
||||
@@ -71,7 +71,7 @@ class TtsService:
|
||||
def cancel(self, req: TtsRequest) -> None:
|
||||
req.cancelled = True
|
||||
req.closed = True
|
||||
debug_log(f"tts cancel id={req.id} sent={req.chunks}", "voice_worker")
|
||||
debug_log(f"tts cancel id={req.id} sent={req.chunks}", "tts")
|
||||
self._maybe_done(req)
|
||||
|
||||
def _maybe_done(self, req: TtsRequest) -> None:
|
||||
@@ -92,11 +92,11 @@ class TtsService:
|
||||
except Exception as e:
|
||||
req.failed = True
|
||||
req.closed = True
|
||||
debug_log(f"tts failed id={req.id} seq={seq}: {type(e).__name__}: {e}", "voice_worker")
|
||||
debug_log(f"tts failed id={req.id} seq={seq}: {type(e).__name__}: {e}", "tts")
|
||||
req.on_error(req, f"{type(e).__name__}: {e}")
|
||||
continue
|
||||
debug_log(f"tts sentence id={req.id} seq={seq} chars={len(text)} "
|
||||
f"ms={int((time.perf_counter() - t0) * 1000)}", "voice_worker")
|
||||
f"ms={int((time.perf_counter() - t0) * 1000)}", "tts")
|
||||
if not req.cancelled:
|
||||
req.chunks += 1
|
||||
req.on_chunk(seq, pcm)
|
||||
|
||||
@@ -32,7 +32,7 @@ class MeloEngine:
|
||||
self.close()
|
||||
raise RuntimeError(f"MeloTTS failed to start: {header.get('error')}")
|
||||
self.native_rate = header["rate"]
|
||||
debug_log(f"melo ready native_rate={self.native_rate}", "voice_worker")
|
||||
debug_log(f"melo ready native_rate={self.native_rate}", "tts")
|
||||
|
||||
def _read(self) -> tuple[dict, bytes]:
|
||||
out = self._proc.stdout
|
||||
@@ -47,7 +47,7 @@ class MeloEngine:
|
||||
def synthesize(self, text: str, rate: int) -> np.ndarray:
|
||||
with self._lock:
|
||||
if self._proc is None or self._proc.poll() is not None:
|
||||
debug_log("melo child not running, restarting", "voice_worker")
|
||||
debug_log("melo child not running, restarting", "tts")
|
||||
self._start()
|
||||
self._proc.stdin.write((json.dumps({"text": text, "rate": rate}) + "\n").encode())
|
||||
self._proc.stdin.flush()
|
||||
|
||||
@@ -311,6 +311,9 @@ never close the connection after the handshake.
|
||||
|
||||
## Debug logging
|
||||
|
||||
`debug_log(..., "voice_worker")` at: connection accepted or refused, settings changed, speaker left, utterance end
|
||||
`debug_log(message, category)` at: connection accepted or refused, settings changed, speaker left, utterance end
|
||||
(speaker, reason, length), each STT batch (kind, size, model time), each TTS sentence (length, time),
|
||||
cancel, and engine failures.
|
||||
cancel, and engine failures. The category names the service, so the app's log screen puts each line
|
||||
in its tab (`app/src/admin.spec.md`, "Logs"): `stt` (utterance ends, STT batches, the Whisper model),
|
||||
`tts` (sentences, cancels, MeloTTS), `llm` (the brain's replies, prepares and judgements),
|
||||
`voice_worker` for the rest (connections, sessions, channels).
|
||||
|
||||
Reference in New Issue
Block a user