repos / pico

pico services - prose.sh, pastes.sh, imgs.sh, feeds.sh, pgs.sh
git clone https://github.com/picosh/pico.git

commit
a4f4855
parent
778efb6
author
Eric Bower
date
2024-12-02 17:47:09 +0000 UTC
chore(logs): shorten timestamp
1 files changed,  +9, -2
M tui/logs/logs.go
+9, -2
 1@@ -6,6 +6,7 @@ import (
 2 	"encoding/json"
 3 	"fmt"
 4 	"strings"
 5+	"time"
 6 
 7 	input "github.com/charmbracelet/bubbles/textinput"
 8 	"github.com/charmbracelet/bubbles/viewport"
 9@@ -205,7 +206,7 @@ func matched(str, match string) bool {
10 }
11 
12 func logToStr(styles common.Styles, data map[string]any, match string) string {
13-	time := utils.AnyToStr(data, "time")
14+	rawtime := utils.AnyToStr(data, "time")
15 	service := utils.AnyToStr(data, "service")
16 	level := utils.AnyToStr(data, "level")
17 	msg := utils.AnyToStr(data, "msg")
18@@ -225,9 +226,15 @@ func logToStr(styles common.Styles, data map[string]any, match string) string {
19 		}
20 	}
21 
22+	date, err := time.Parse(time.RFC3339Nano, rawtime)
23+	dateStr := rawtime
24+	if err == nil {
25+		dateStr = date.Format(time.RFC3339)
26+	}
27+
28 	acc := fmt.Sprintf(
29 		"%s %s %s %s %s %s %s",
30-		time,
31+		dateStr,
32 		service,
33 		levelView(styles, level),
34 		msg,