From 896e1a2abb09254ec37952869e40b2eeee5f0200 Mon Sep 17 00:00:00 2001 From: Kevin Wan Date: Tue, 27 Aug 2024 22:01:01 +0800 Subject: [PATCH] chore: refactor logx file time format (#4335) --- core/logx/logs_test.go | 13 +++++++------ core/logx/rotatelogger.go | 3 ++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/core/logx/logs_test.go b/core/logx/logs_test.go index 4c831a7c..c79c68da 100644 --- a/core/logx/logs_test.go +++ b/core/logx/logs_test.go @@ -850,12 +850,13 @@ func doTestStructedLogConsole(t *testing.T, w *mockWriter, write func(...any)) { func testSetLevelTwiceWithMode(t *testing.T, mode string, w *mockWriter) { writer.Store(nil) SetUp(LogConf{ - Mode: mode, - Level: "debug", - Path: "/dev/null", - Encoding: plainEncoding, - Stat: false, - TimeFormat: time.RFC3339, + Mode: mode, + Level: "debug", + Path: "/dev/null", + Encoding: plainEncoding, + Stat: false, + TimeFormat: time.RFC3339, + FileTimeFormat: time.DateTime, }) SetUp(LogConf{ Mode: mode, diff --git a/core/logx/rotatelogger.go b/core/logx/rotatelogger.go index 58d837ae..fc9c4fc2 100644 --- a/core/logx/rotatelogger.go +++ b/core/logx/rotatelogger.go @@ -30,7 +30,8 @@ const ( var ( // ErrLogFileClosed is an error that indicates the log file is already closed. ErrLogFileClosed = errors.New("error: log file closed") - fileTimeFormat = time.RFC3339 + + fileTimeFormat = time.RFC3339 ) type (