Filter logs to WARNING+

This commit is contained in:
NeilClack
2026-05-10 22:51:26 -05:00
parent 87d484353f
commit 870d73d6e1
+5 -2
View File
@@ -4,7 +4,7 @@ import (
"fmt" "fmt"
"strings" "strings"
"time" "time"
"slices"
"github.com/go-gl/gl/v3.3-core/gl" "github.com/go-gl/gl/v3.3-core/gl"
"github.com/go-gl/mathgl/mgl32" "github.com/go-gl/mathgl/mgl32"
"github.com/veandco/go-sdl2/sdl" "github.com/veandco/go-sdl2/sdl"
@@ -53,13 +53,16 @@ func (p *LogViewerPage) Init(ctx *PageCtx) error {
// wrapped := wrapText(formatted, 100) // wrapped := wrapText(formatted, 100)
// p.lines = append(p.lines, strings.Split(wrapped, "\n")...) // p.lines = append(p.lines, strings.Split(wrapped, "\n")...)
// } // }
displayLevels := []string{"WARNING", "ERROR", "FATAL"}
for _, entry := range logs { for _, entry := range logs {
if slices.Contains(displayLevels, entry.Level) {
logTime := time.UnixMilli(entry.Timestamp) logTime := time.UnixMilli(entry.Timestamp)
timeStr := logTime.Format("2006-01-02 15:04:05") timeStr := logTime.Format("2006-01-02 15:04")
line := fmt.Sprintf("[%s] [%s] %s", timeStr, entry.Level, entry.Message) line := fmt.Sprintf("[%s] [%s] %s", timeStr, entry.Level, entry.Message)
p.lines = append(p.lines, line) p.lines = append(p.lines, line)
} }
}
applicationFont := "Roboto-Regular" applicationFont := "Roboto-Regular"