summaryrefslogtreecommitdiff
path: root/internal/lsp/handlers.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-08-16 16:26:12 +0300
committerPaul Buetow <paul@buetow.org>2025-08-16 16:26:12 +0300
commit833bb66706dd991ecd3973da360c472d818e970a (patch)
tree62d8465b305883af1002063eb54ef38a08de299d /internal/lsp/handlers.go
parent148cda5f7ed4513528e3a46164b990708eeb1bc6 (diff)
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
Diffstat (limited to 'internal/lsp/handlers.go')
-rw-r--r--internal/lsp/handlers.go29
1 files changed, 15 insertions, 14 deletions
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