Skip to content

Commit ba87c3a

Browse files
committed
feat(logging): 使用常量定义时间格式化,提升代码可维护性
1 parent 4af69bf commit ba87c3a

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

constants/time.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package constants
2+
3+
const FORMATE_TIME = "2006-01-02 15:04:05" // 时间格式化

internal/logging/service.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func (s *serviceLoggerSetting) Format(entry *logrus.Entry) ([]byte, error) {
3838
b = entry.Buffer
3939
}
4040
// 时间格式化
41-
formatTime := entry.Time.Format("2006-01-02 15:04:05")
41+
formatTime := entry.Time.Format(constants.FORMATE_TIME)
4242

4343
fmt.Fprintf(
4444
b,

0 commit comments

Comments
 (0)