feat(tui): compact log sidebar with severity icons
Replace full viewLogsTab with compact sidebar renderer for the 70/30 monitors split. Single-char severity icons (▼▲◆●·), truncated messages, no header chrome. Renders directly from engine logs without viewport.
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
package tui
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func (m Model) renderCompactLogLine(line string, maxW int) string {
|
||||
sev := classifyLog(line)
|
||||
|
||||
var tag string
|
||||
switch sev {
|
||||
case severityDown:
|
||||
tag = m.st.dangerStyle.Render("▼")
|
||||
case severityUp:
|
||||
tag = m.st.specialStyle.Render("▲")
|
||||
case severityWarn:
|
||||
tag = m.st.warnStyle.Render("◆")
|
||||
case severitySystem:
|
||||
tag = m.st.titleStyle.Render("●")
|
||||
default:
|
||||
tag = m.st.subtleStyle.Render("·")
|
||||
}
|
||||
|
||||
ts := ""
|
||||
msg := line
|
||||
if len(line) > 10 && line[0] == '[' {
|
||||
if idx := strings.Index(line, "]"); idx > 0 && idx < 12 {
|
||||
ts = line[1:idx]
|
||||
msg = strings.TrimSpace(line[idx+1:])
|
||||
}
|
||||
}
|
||||
|
||||
msgW := maxW - 10
|
||||
if msgW < 10 {
|
||||
msgW = 10
|
||||
}
|
||||
msg = limitStr(msg, msgW)
|
||||
|
||||
if ts != "" {
|
||||
return fmt.Sprintf(" %s %s %s", m.st.subtleStyle.Render(ts), tag, msg)
|
||||
}
|
||||
return fmt.Sprintf(" %s %s", tag, msg)
|
||||
}
|
||||
|
||||
func (m Model) viewLogsSidebar(width int) string {
|
||||
logs := m.engine.GetLogs()
|
||||
if len(logs) == 0 {
|
||||
return m.st.subtleStyle.Render(" No logs yet")
|
||||
}
|
||||
|
||||
var lines []string
|
||||
for _, line := range logs {
|
||||
if strings.TrimSpace(line) == "" {
|
||||
continue
|
||||
}
|
||||
if m.logFilterImportant && !isImportantLog(classifyLog(line)) {
|
||||
continue
|
||||
}
|
||||
lines = append(lines, m.renderCompactLogLine(line, width))
|
||||
}
|
||||
|
||||
return strings.Join(lines, "\n")
|
||||
}
|
||||
Reference in New Issue
Block a user