fix: log formater not take effect if write file not enabled

This commit is contained in:
Mmx
2024-09-24 23:48:46 +08:00
parent 78a1b2662d
commit 5fa863a35e

View File

@@ -1,12 +1,12 @@
package config package config
import ( import (
nested "github.com/antonfisher/nested-logrus-formatter"
"io" "io"
"os" "os"
"strings" "strings"
"time" "time"
nested "github.com/antonfisher/nested-logrus-formatter"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
) )
@@ -41,6 +41,7 @@ func initLog() {
//设置双重输出 //设置双重输出
mw := io.MultiWriter(os.Stdout, f) mw := io.MultiWriter(os.Stdout, f)
Logger.SetOutput(mw) Logger.SetOutput(mw)
}
//设置输出格式 //设置输出格式
Logger.SetFormatter(&nested.Formatter{ Logger.SetFormatter(&nested.Formatter{
@@ -49,4 +50,3 @@ func initLog() {
TimestampFormat: "2006-01-02 15:04:05", TimestampFormat: "2006-01-02 15:04:05",
}) })
} }
}