repos / pico

pico services mono repo
git clone https://github.com/picosh/pico.git

commit
8c509c5
parent
a812bed
author
Eric Bower
date
2025-01-28 20:56:23 -0500 EST
chore(pico): hide status section in log line if it is empty
2 files changed,  +16, -3
M pgs/web_asset_handler.go
+0, -1
1@@ -136,7 +136,6 @@ func (h *ApiAssetHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
2 		fpath := fp.Filepath
3 		attempts = append(attempts, fpath)
4 		logger = logger.With("object", fpath)
5-		logger.Info("serving object")
6 		c, info, err = h.Cfg.Storage.ServeObject(
7 			h.Bucket,
8 			fpath,
M tui/logs/logs.go
+16, -2
 1@@ -232,7 +232,19 @@ func logToStr(styles common.Styles, data map[string]any, match string) string {
 2 		dateStr = date.Format(time.RFC3339)
 3 	}
 4 
 5-	acc := fmt.Sprintf(
 6+	if status == 0 {
 7+		return fmt.Sprintf(
 8+			"%s %s %s %s %s %s",
 9+			dateStr,
10+			service,
11+			levelView(styles, level),
12+			msg,
13+			styles.Error.Render(errMsg),
14+			url,
15+		)
16+	}
17+
18+	return fmt.Sprintf(
19 		"%s %s %s %s %s %s %s",
20 		dateStr,
21 		service,
22@@ -242,11 +254,13 @@ func logToStr(styles common.Styles, data map[string]any, match string) string {
23 		statusView(styles, int(status)),
24 		url,
25 	)
26-	return acc
27 }
28 
29 func statusView(styles common.Styles, status int) string {
30 	statusStr := fmt.Sprintf("%d", status)
31+	if status == 0 {
32+		return statusStr
33+	}
34 	if status >= 200 && status < 300 {
35 		return statusStr
36 	}