diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2023-05-05 17:55:50 +0200 |
|---|---|---|
| committer | Aleksandr Nogikh <wp32pw@gmail.com> | 2023-05-05 18:39:28 +0200 |
| commit | 4cec9341d5812957f3f34bafeef1c11036e286c0 (patch) | |
| tree | a6d71f9a265d504c37eb0b9a97944921e868b748 /pkg | |
| parent | de870ca5ea0b42afdf670fa407254dc617342cc3 (diff) | |
pkg/log: don't prepend timestamp twice
golog.Printf also prepends time, so we only need to do it for log
caching.
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/log/log.go | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/pkg/log/log.go b/pkg/log/log.go index 2a2fd6481..aee63e6e2 100644 --- a/pkg/log/log.go +++ b/pkg/log/log.go @@ -90,9 +90,6 @@ func Fatalf(msg string, args ...interface{}) { func writeMessage(v int, severity, msg string, args ...interface{}) { var sb strings.Builder - if prependTime { - sb.WriteString(time.Now().Format("2006/01/02 15:04:05 ")) - } if severity != "" { fmt.Fprintf(&sb, "[%s] ", severity) } @@ -110,7 +107,11 @@ func writeRawMessage(v int, msg string) { if cacheMem < 0 { panic("log cache size underflow") } - cacheEntries[cachePos] = msg + timeStr := "" + if prependTime { + timeStr = time.Now().Format("2006/01/02 15:04:05 ") + } + cacheEntries[cachePos] = timeStr + msg cacheMem += len(cacheEntries[cachePos]) cachePos++ if cachePos == len(cacheEntries) { |
