From 146ef4b7ef33c7bc396a0f4d2f89192b95398aa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=B6=9B?= Date: Fri, 9 Sep 2022 08:49:53 +0800 Subject: [PATCH] =?UTF-8?q?enhance(log):=E6=94=B9=E8=BF=9B=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E7=9A=84=E6=BB=9A=E5=8A=A8=E4=BF=9D=E5=AD=98=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logger/rolling.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/logger/rolling.go b/logger/rolling.go index b7279a4..52fe692 100644 --- a/logger/rolling.go +++ b/logger/rolling.go @@ -1,11 +1,9 @@ package logger import ( - "fmt" "io" "log" "os" - "time" "gopkg.in/natefinch/lumberjack.v2" ) @@ -16,12 +14,10 @@ func newRollingWriter() io.Writer { return nil } - now := time.Now() - return &lumberjack.Logger{ - Filename: fmt.Sprintf("log/%04d-%02d-%02d.log", now.Year(), now.Month(), now.Day()), - MaxBackups: 0, // files - MaxSize: 200, // megabytes - MaxAge: 0, // days + Filename: "log/electricity_bill_service.log", + MaxBackups: 366 * 10, // files + MaxSize: 200, // megabytes + MaxAge: 366 * 10, // days } }