Skip to content

Commit

Permalink
输出到文件的日志不带有字体颜色
Browse files Browse the repository at this point in the history
  • Loading branch information
karldoenitz committed Dec 22, 2024
1 parent f963a59 commit 7de5ec8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions logger/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func initLogger() {
Warning.Level = WarningLevel
// 将错误日志写入log文件
Error = &TiLog{}
Error.Logger = log.New(io.MultiWriter(file, os.Stderr), "\x1b[41m ERROR \x1b[0m ", log.Ldate|log.Ltime)
Error.Logger = log.New(file, " ERROR ", log.Ldate|log.Ltime)
Error.Level = ErrorLevel
}

Expand Down Expand Up @@ -201,7 +201,7 @@ func InitTrace(level string) {
break
default:
logFile := logFileMapping[level]
Trace.Logger = log.New(io.MultiWriter(logFile, os.Stderr), "\x1b[42m TRACE \x1b[0m ", log.Ldate|log.Ltime)
Trace.Logger = log.New(logFile, " TRACE ", log.Ldate|log.Ltime)
}
}

Expand All @@ -217,7 +217,7 @@ func InitInfo(level string) {
break
default:
logFile := logFileMapping[level]
Info.Logger = log.New(io.MultiWriter(logFile, os.Stderr), "\x1b[44m INFO \x1b[0m ", log.Ldate|log.Ltime)
Info.Logger = log.New(logFile, " INFO ", log.Ldate|log.Ltime)
break
}
}
Expand All @@ -234,7 +234,7 @@ func InitWarning(level string) {
break
default:
logFile := logFileMapping[level]
Warning.Logger = log.New(io.MultiWriter(logFile, os.Stderr), "\x1b[43m WARNING \x1b[0m ", log.Ldate|log.Ltime)
Warning.Logger = log.New(logFile, " WARNING ", log.Ldate|log.Ltime)
break
}
}
Expand All @@ -251,7 +251,7 @@ func InitError(level string) {
break
default:
logFile := logFileMapping[level]
Error.Logger = log.New(io.MultiWriter(logFile, os.Stderr), " ERROR: ", log.Ldate|log.Ltime)
Error.Logger = log.New(logFile, " ERROR: ", log.Ldate|log.Ltime)
break
}
}
Expand Down

0 comments on commit 7de5ec8

Please sign in to comment.