From 833bb66706dd991ecd3973da360c472d818e970a Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 16 Aug 2025 16:26:12 +0300 Subject: logging: migrate LSP logs to global singleton (internal/logging); use consistent colors/prefix; refactor LLM provider to use global logger and remove per-client loggers --- internal/lsp/handlers.go | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'internal/lsp/handlers.go') diff --git a/internal/lsp/handlers.go b/internal/lsp/handlers.go index 8a782c4..1e77141 100644 --- a/internal/lsp/handlers.go +++ b/internal/lsp/handlers.go @@ -1,14 +1,15 @@ package lsp import ( - "context" - "encoding/json" - "fmt" - "hexai/internal" - "hexai/internal/llm" - "os" - "strings" - "time" + "context" + "encoding/json" + "fmt" + "hexai/internal" + "hexai/internal/llm" + "hexai/internal/logging" + "os" + "strings" + "time" ) func (s *Server) handle(req Request) { @@ -52,7 +53,7 @@ func (s *Server) handleInitialize(req Request) { } func (s *Server) handleInitialized() { - s.logger.Println("client initialized") + logging.Logf("lsp ", "client initialized") } func (s *Server) handleShutdown(req Request) { @@ -126,7 +127,7 @@ func (s *Server) buildDocString(p CompletionParams, above, current, below, funcC } func (s *Server) logCompletionContext(p CompletionParams, above, current, below, funcCtx string) { - s.logger.Printf("completion ctx uri=%s line=%d char=%d above=%q current=%q below=%q function=%q", + logging.Logf("lsp ", "completion ctx uri=%s line=%d char=%d above=%q current=%q below=%q function=%q", p.TextDocument.URI, p.Position.Line, p.Position.Character, trimLen(above), trimLen(current), trimLen(below), trimLen(funcCtx)) } @@ -145,10 +146,10 @@ func (s *Server) tryLLMCompletion(p CompletionParams, above, current, below, fun } text, err := s.llmClient.Chat(ctx, messages, llm.WithMaxTokens(s.maxTokens), llm.WithTemperature(0.2)) - if err != nil { - s.logger.Printf("llm completion error: %v", err) - return nil, false - } + if err != nil { + logging.Logf("lsp ", "llm completion error: %v", err) + return nil, false + } cleaned := strings.TrimSpace(text) if cleaned == "" { return nil, false -- cgit v1.2.3