Finish the logger maintain work.
This commit is contained in:
@ -67,6 +67,7 @@ func (this *Logger) Init() {
|
||||
//日志需要自我备份,自我维护。明天第一秒触发
|
||||
nextTime := FirstSecondOfDay(Tomorrow())
|
||||
duration := nextTime.Sub(time.Now())
|
||||
go this.Info("%vs后将进行下一次日志维护 下次时间%v ", int64(duration/time.Second), nextTime)
|
||||
this.maintainTimer = time.AfterFunc(duration, func() {
|
||||
go this.maintain()
|
||||
})
|
||||
@ -100,12 +101,12 @@ func (this *Logger) maintain() {
|
||||
now := time.Now()
|
||||
nextTime := FirstSecondOfDay(Tomorrow())
|
||||
duration := nextTime.Sub(now)
|
||||
go this.Info("%vs后将进行下一次日志维护 下次时间维护时间:%v ", int64(duration/time.Second), nextTime)
|
||||
this.maintainTimer = time.AfterFunc(duration, func() {
|
||||
go this.maintain()
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
//日志名称
|
||||
func (this *Logger) fileName() string {
|
||||
return GetLogPath() + "/tank.log"
|
||||
|
@ -30,13 +30,13 @@ func FirstSecondOfDay(day time.Time) time.Time {
|
||||
//明天此刻的时间
|
||||
func Tomorrow() time.Time {
|
||||
tomorrow := time.Now()
|
||||
tomorrow.AddDate(0, 0, 1)
|
||||
tomorrow = tomorrow.AddDate(0, 0, 1)
|
||||
return tomorrow
|
||||
}
|
||||
|
||||
//昨天此刻的时间
|
||||
func Yesterday() time.Time {
|
||||
tomorrow := time.Now()
|
||||
tomorrow.AddDate(0, 0, -1)
|
||||
tomorrow = tomorrow.AddDate(0, 0, -1)
|
||||
return tomorrow
|
||||
}
|
||||
|
Reference in New Issue
Block a user