From b9a6856ff5b10db149ef69484a24e1b3b605cdb7 Mon Sep 17 00:00:00 2001 From: James Elliott Date: Tue, 28 Feb 2023 20:40:04 +1100 Subject: [PATCH] fix(logging): injected time format inconsistent (#5004) This fixes an issue where the injected log time format is inconsistent with a normalized time format. This adjusts it to use a RFC3339 format. --- docs/content/en/configuration/miscellaneous/logging.md | 3 ++- internal/logging/logger.go | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/content/en/configuration/miscellaneous/logging.md b/docs/content/en/configuration/miscellaneous/logging.md index 8c3728856..278511f08 100644 --- a/docs/content/en/configuration/miscellaneous/logging.md +++ b/docs/content/en/configuration/miscellaneous/logging.md @@ -75,7 +75,8 @@ level to `debug` or `trace` this will generate large amount of log entries. Admi they rotate and/or truncate the logs over time to prevent significant long-term disk usage. If you include the value `%d` in the filename it will replace this value with a date time indicative of the time -the logger was initialized using `2006-02-01T150405Z` as the format. +the logger was initialized using [RFC3339](https://datatracker.ietf.org/doc/html/rfc3339) as the format which is +represented as `2006-01-02T15:04:05Z07:00` in go. #### File Path Examples diff --git a/internal/logging/logger.go b/internal/logging/logger.go index 3c5a549a4..34dddea8b 100644 --- a/internal/logging/logger.go +++ b/internal/logging/logger.go @@ -50,7 +50,7 @@ func InitializeLogger(config schema.LogConfiguration, log bool) error { } if config.FilePath != "" { - filePath := strings.ReplaceAll(config.FilePath, "%d", time.Now().Format("2006-02-01T150405Z")) + filePath := strings.ReplaceAll(config.FilePath, "%d", time.Now().Format(time.RFC3339)) f, err := os.OpenFile(filePath, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600)