summaryrefslogtreecommitdiff
path: root/internal/logging/chatlogger.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-08-17 22:46:25 +0300
committerPaul Buetow <paul@buetow.org>2025-08-17 22:46:25 +0300
commitc83acd3f5749fe240464283a43f8b03797a1b544 (patch)
tree97f32c7853af6255bdb430b2670f5d53e8158ac7 /internal/logging/chatlogger.go
parent95ecff336b2f8315ad37daeb006d1639d1710ed0 (diff)
refactor as per manual code reviews
Diffstat (limited to 'internal/logging/chatlogger.go')
-rw-r--r--internal/logging/chatlogger.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/internal/logging/chatlogger.go b/internal/logging/chatlogger.go
new file mode 100644
index 0000000..b6b84a3
--- /dev/null
+++ b/internal/logging/chatlogger.go
@@ -0,0 +1,28 @@
+package logging
+
+// ChatLogger provides a structured way to log chat interactions.
+type ChatLogger struct {
+ Provider string
+}
+
+// NewChatLogger creates a new ChatLogger for a given provider.
+func NewChatLogger(provider string) *ChatLogger {
+ return &ChatLogger{Provider: provider}
+}
+
+// LogStart logs the beginning of a chat or stream interaction.
+func (cl *ChatLogger) LogStart(stream bool, model string, temp float64, maxTokens int, stop []string, messages []struct {
+ Role string
+ Content string
+}) {
+ chatOrStream := "chat"
+ if stream {
+ chatOrStream = "stream"
+ }
+ Logf("llm/"+cl.Provider+" ", "%s start model=%s temp=%.2f max_tokens=%d stop=%d messages=%d",
+ chatOrStream, model, temp, maxTokens, len(stop), len(messages))
+ for i, m := range messages {
+ Logf("llm/"+cl.Provider+" ", "msg[%d] role=%s size=%d preview=%s%s%s",
+ i, m.Role, len(m.Content), AnsiCyan, PreviewForLog(m.Content), AnsiBase)
+ }
+}