Skip to content

Commit

Permalink
chore(logs): shorten timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
neurosnap committed Dec 2, 2024
1 parent 778efb6 commit a4f4855
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tui/logs/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/json"
"fmt"
"strings"
"time"

input "github.com/charmbracelet/bubbles/textinput"
"github.com/charmbracelet/bubbles/viewport"
Expand Down Expand Up @@ -205,7 +206,7 @@ func matched(str, match string) bool {
}

func logToStr(styles common.Styles, data map[string]any, match string) string {
time := utils.AnyToStr(data, "time")
rawtime := utils.AnyToStr(data, "time")
service := utils.AnyToStr(data, "service")
level := utils.AnyToStr(data, "level")
msg := utils.AnyToStr(data, "msg")
Expand All @@ -225,9 +226,15 @@ func logToStr(styles common.Styles, data map[string]any, match string) string {
}
}

date, err := time.Parse(time.RFC3339Nano, rawtime)
dateStr := rawtime
if err == nil {
dateStr = date.Format(time.RFC3339)
}

acc := fmt.Sprintf(
"%s %s %s %s %s %s %s",
time,
dateStr,
service,
levelView(styles, level),
msg,
Expand Down

0 comments on commit a4f4855

Please sign in to comment.