|
@@ -2,13 +2,11 @@ package utils
|
|
|
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
- "fmt"
|
|
|
"github.com/beego/beego/v2/core/logs"
|
|
|
"github.com/sirupsen/logrus"
|
|
|
"gopkg.in/natefinch/lumberjack.v2"
|
|
|
"os"
|
|
|
"path"
|
|
|
- "time"
|
|
|
)
|
|
|
|
|
|
const (
|
|
@@ -33,7 +31,7 @@ func init() {
|
|
|
}
|
|
|
logFile := LogFile
|
|
|
if logFile == "" {
|
|
|
- logFile = fmt.Sprintf("%s.log", time.Now().Format(FormatDateUnSpace))
|
|
|
+ logFile = "filelog.log"
|
|
|
}
|
|
|
os.MkdirAll(logPath, os.ModePerm)
|
|
|
|
|
@@ -80,7 +78,7 @@ func initBinlog() {
|
|
|
}
|
|
|
binlogFile := BinLogFile
|
|
|
if binlogFile == "" {
|
|
|
- binlogFile = fmt.Sprintf("%s.log", time.Now().Format(FormatDateUnSpace))
|
|
|
+ binlogFile = "binlog.log"
|
|
|
}
|
|
|
os.MkdirAll(binlogPath, os.ModePerm)
|
|
|
logFileName := path.Join(binlogPath, binlogFile)
|
|
@@ -102,7 +100,7 @@ func initApiLog() {
|
|
|
}
|
|
|
logFile := ApiLogFile
|
|
|
if logFile == "" {
|
|
|
- logFile = fmt.Sprintf("%s.log", time.Now().Format(FormatDateUnSpace))
|
|
|
+ logFile = "apilog.log"
|
|
|
}
|
|
|
os.MkdirAll(logPath, os.ModePerm)
|
|
|
|
|
@@ -126,7 +124,7 @@ func initFileLogData() {
|
|
|
}
|
|
|
logFile := LogDataFile
|
|
|
if logFile == "" {
|
|
|
- logFile = fmt.Sprintf("%s.log", time.Now().Format(FormatDateUnSpace))
|
|
|
+ logFile = "datalog.log"
|
|
|
}
|
|
|
os.MkdirAll(logPath, os.ModePerm)
|
|
|
|
|
@@ -152,7 +150,7 @@ func getDefaultLogrusConfig(logFile string) (config *lumberjack.Logger) {
|
|
|
config = &lumberjack.Logger{
|
|
|
Filename: logFile, //日志文件位置
|
|
|
MaxSize: 256, // 单文件最大容量,单位是MB
|
|
|
- MaxBackups: 0, // 最大保留过期文件个数
|
|
|
+ MaxBackups: 0, // 最大保留过期文件个数,0表示默认保留
|
|
|
MaxAge: LogMaxDays, // 保留过期文件的最大时间间隔,单位是天
|
|
|
Compress: true, // 是否需要压缩滚动日志, 使用的 gzip 压缩
|
|
|
LocalTime: true,
|