修改日志路径bug

This commit is contained in:
chejiulong 2023-02-27 16:47:07 +08:00
parent cb54278363
commit 6d462b1067
3 changed files with 5 additions and 3 deletions

Binary file not shown.

Binary file not shown.

View File

@ -193,7 +193,8 @@ func main() {
os.Exit(1)
}
applogger = logrus.New()
logPath := filepath.Join(executableDir, "logs", time.Now().Format("2006_01"))
logPath = filepath.Join(executableDir, "logs", time.Now().Format("2006_01"))
err = os.MkdirAll(logPath, 0755)
logFileName := "sms_processing_" + time.Now().Format("2006_01_02") + ".log"
logFileHook := &lumberjack.Logger{
Filename: filepath.Join(logPath, logFileName),
@ -210,8 +211,9 @@ func main() {
select {
case <-ticker.C:
// 定时器触发时执行的任务函数
logFileName := "sms_processing_" + time.Now().Format("2006_01_02") + ".log"
logFileHook := &lumberjack.Logger{
logPath = filepath.Join(executableDir, "logs", time.Now().Format("2006_01"))
logFileName = "sms_processing_" + time.Now().Format("2006_01_02") + ".log"
logFileHook = &lumberjack.Logger{
Filename: filepath.Join(logPath, logFileName),
}
applogger.SetOutput(logFileHook)