@@ -9,11 +9,70 @@ import (
9
9
)
10
10
11
11
// formatLogEntry formats a log entry with colors
12
- func (m * DashboardModel ) formatLogEntry (entry LogEntry , availableWidth int ) string {
12
+ func (m * DashboardModel ) formatLogEntry (entry LogEntry , availableWidth int , isSelected bool ) string {
13
13
// Use receive time for display
14
14
timestamp := entry .Timestamp .Format ("15:04:05" )
15
15
16
- // Color severity levels
16
+ // If selected, apply selection style to entire row
17
+ if isSelected {
18
+ // Format the entire row without individual component styling
19
+ severity := fmt .Sprintf ("%-5s" , entry .Severity )
20
+
21
+ var logLine string
22
+ if m .showColumns {
23
+ // Extract host.name and service.name from OTLP attributes
24
+ host := entry .Attributes ["host.name" ]
25
+ service := entry .Attributes ["service.name" ]
26
+
27
+ // Truncate to fit column width
28
+ if len (host ) > 12 {
29
+ host = host [:9 ] + "..."
30
+ }
31
+ if len (service ) > 16 {
32
+ service = service [:13 ] + "..."
33
+ }
34
+
35
+ // Format fixed-width columns
36
+ hostCol := fmt .Sprintf ("%-12s" , host )
37
+ serviceCol := fmt .Sprintf ("%-16s" , service )
38
+
39
+ // Calculate remaining space for message
40
+ // Use same calculation as non-selected: availableWidth - 18 - columnsWidth
41
+ columnsWidth := 30 // 12 + 16 + 2 spaces
42
+ maxMessageLen := availableWidth - 18 - columnsWidth
43
+ if maxMessageLen < 10 {
44
+ maxMessageLen = 10
45
+ }
46
+
47
+ message := entry .Message
48
+ if len (message ) > maxMessageLen {
49
+ message = message [:maxMessageLen - 3 ] + "..."
50
+ }
51
+
52
+ logLine = fmt .Sprintf ("%s %-5s %s %s %s" , timestamp , severity , hostCol , serviceCol , message )
53
+ } else {
54
+ // Calculate space for message - use same as non-selected: availableWidth - 18
55
+ maxMessageLen := availableWidth - 18
56
+ if maxMessageLen < 10 {
57
+ maxMessageLen = 10
58
+ }
59
+
60
+ message := entry .Message
61
+ if len (message ) > maxMessageLen {
62
+ message = message [:maxMessageLen - 3 ] + "..."
63
+ }
64
+
65
+ logLine = fmt .Sprintf ("%s %-5s %s" , timestamp , severity , message )
66
+ }
67
+
68
+ // Apply selection style to entire line
69
+ selectedStyle := lipgloss .NewStyle ().
70
+ Background (ColorBlue ).
71
+ Foreground (ColorWhite )
72
+ return selectedStyle .Render (logLine )
73
+ }
74
+
75
+ // Normal (non-selected) formatting with individual component colors
17
76
severityColor := ColorGray
18
77
switch strings .ToUpper (entry .Severity ) {
19
78
case "FATAL" , "CRITICAL" :
0 commit comments