添加自动文件压缩的实现
This commit is contained in:
@@ -23,6 +23,10 @@ func (l *Logger) delete() {
|
||||
fmt.Println("清理日志文件异常:", r)
|
||||
}
|
||||
}()
|
||||
// 先清掉「压缩完成但源文件没删掉」留下的冗余文件
|
||||
if err := l.healCompressedLeftovers(); err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
if err := l.walkAndDel(); err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
@@ -59,7 +63,8 @@ func (l *Logger) walkAndDel() error {
|
||||
if !isEmptyDir(path) {
|
||||
return nil
|
||||
}
|
||||
} else if filepath.Ext(path) != ".log" {
|
||||
} else if ext := filepath.Ext(path); ext != ".log" && ext != ".gz" {
|
||||
// 只清理日志与压缩归档
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user