Skip to content
This repository has been archived by the owner on Feb 13, 2025. It is now read-only.

Commit

Permalink
feat: use strings builder for joining together items in format
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Gleich <git@mattglei.ch>
  • Loading branch information
gleich committed Dec 3, 2024
1 parent a38e432 commit 43981bc
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions log.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,18 @@ const (
)

func format(level logLevel, color lipgloss.Style, v ...any) string {
var joined string
for _, item := range v {
joined = fmt.Sprintf("%v %v", joined, item)
var joined strings.Builder
for i, item := range v {
if i > 0 {
joined.WriteString(" ")
}
fmt.Fprint(&joined, item)
}
return fmt.Sprintf(
"%s %s %s",
time.Now().In(logger.timezone).Format(logger.timeFormat),
color.Render(string(level)),
strings.TrimPrefix(joined, " "),
strings.TrimPrefix(joined.String(), " "),
)
}

Expand Down

0 comments on commit 43981bc

Please sign in to comment.