Bläddra i källkod

fix: log display

adamdottv 9 månader sedan
förälder
incheckning
f7849c2d59
2 ändrade filer med 11 tillägg och 1 borttagningar
  1. 11 0
      internal/tui/components/logs/details.go
  2. 0 1
      internal/tui/components/logs/table.go

+ 11 - 0
internal/tui/components/logs/details.go

@@ -1,6 +1,8 @@
 package logs
 
 import (
+	"bytes"
+	"encoding/json"
 	"fmt"
 	"strings"
 	"time"
@@ -96,6 +98,15 @@ func (i *detailCmp) updateContent() {
 		valueStyle := lipgloss.NewStyle().Foreground(t.Text())
 
 		for key, value := range i.currentLog.Attributes {
+			// if value is JSON, render it with indentation
+			if strings.HasPrefix(value, "{") {
+				var indented bytes.Buffer
+				if err := json.Indent(&indented, []byte(value), "", "  "); err != nil {
+					indented.WriteString(value)
+				}
+				value = indented.String()
+			}
+
 			attrLine := fmt.Sprintf("%s: %s",
 				keyStyle.Render(key),
 				valueStyle.Render(value),

+ 0 - 1
internal/tui/components/logs/table.go

@@ -81,7 +81,6 @@ func (i *tableCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 		return i, i.fetchLogs()
 
 	case pubsub.Event[logging.Log]:
-		// Only handle created events
 		if msg.Type == logging.EventLogCreated {
 			// Add the new log to our list
 			i.logs = append([]logging.Log{msg.Payload}, i.logs...)