From 2f794f549fa4a156b04d31c7a851a3bc1b98df19 Mon Sep 17 00:00:00 2001 From: zicla Date: Mon, 10 Dec 2018 02:05:52 +0800 Subject: [PATCH] Fix the total tings of logger. --- rest/logger.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/rest/logger.go b/rest/logger.go index 0c759d1..6c35923 100644 --- a/rest/logger.go +++ b/rest/logger.go @@ -65,14 +65,10 @@ func (this *Logger) Init() { this.openFile() //日志需要自我备份,自我维护。明天第一秒触发 - //nextTime := FirstSecondOfDay(Tomorrow()) - //duration := nextTime.Sub(time.Now()) - - nextTime := time.Now() - nextTime = nextTime.Add(time.Second * 10) + nextTime := FirstSecondOfDay(Tomorrow()) duration := nextTime.Sub(time.Now()) - this.Info("下一次日志维护时间%v 距当前 %ds ", ConvertTimeToDateTimeString(nextTime), duration/time.Second) + this.Info("下一次日志维护时间%s 距当前 %ds ", ConvertTimeToDateTimeString(nextTime), duration/time.Second) this.maintainTimer = time.AfterFunc(duration, func() { go SafeMethod(this.maintain) }) @@ -106,7 +102,7 @@ func (this *Logger) maintain() { now := time.Now() nextTime := FirstSecondOfDay(Tomorrow()) duration := nextTime.Sub(now) - this.Info("下次维护时间:%v ", int64(duration/time.Second), nextTime) + this.Info("下次维护时间:%s ", ConvertTimeToDateTimeString(nextTime)) this.maintainTimer = time.AfterFunc(duration, func() { go SafeMethod(this.maintain) })