Логирование: ревью всего кода и рефакторинг в соответствии с конвенциями

This commit is contained in:
av
2026-06-28 20:13:40 +03:00
parent c739a20749
commit 9cfccc7b4a
24 changed files with 473 additions and 203 deletions
+6 -4
View File
@@ -7,6 +7,7 @@ import (
"strings"
"git.vakhrushev.me/av/jellybit/internal/llm"
"git.vakhrushev.me/av/jellybit/internal/logctx"
)
// systemPrompt инструктирует модель вытащить из вольного контекста короткое
@@ -56,6 +57,7 @@ func (n *Namer) extractViaLLM(ctx context.Context, contextText, hint string) (ex
{Role: llm.RoleUser, Content: user},
}
log := logctx.FromOr(ctx, n.log)
for attempt := 1; attempt <= n.attempts; attempt++ {
resp, err := n.provider.Complete(ctx, llm.Request{
Messages: msgs,
@@ -63,9 +65,9 @@ func (n *Namer) extractViaLLM(ctx context.Context, contextText, hint string) (ex
Temperature: &temp,
})
if err != nil {
// Транспортная ошибка/таймаут: дальше пробовать смысла нет —
// уходим в фолбек, приём не валим.
n.log.Warn("naming: llm complete failed, will fall back", "err", err)
// Транспортная ошибка/таймаут залогирована клиентом LLM (ext.*);
// здесь — доменное решение «уходим в фолбек, приём не валим».
log.Debug("naming llm failed, using fallback")
return extracted{}, false
}
@@ -73,7 +75,7 @@ func (n *Namer) extractViaLLM(ctx context.Context, contextText, hint string) (ex
if perr == nil {
return ex, true
}
n.log.Warn("naming: unparsed llm response", "attempt", attempt, "err", perr)
log.Warn("naming llm response unparsed", "attempt", attempt, "error", perr)
msgs = append(msgs,
llm.Message{Role: llm.RoleAssistant, Content: resp.Content},
llm.Message{Role: llm.RoleUser, Content: "Ответ невалиден: " + perr.Error() +