日志等级bug修复

This commit is contained in:
Pan Qiancheng 2025-04-13 17:03:13 +08:00
parent 0bb14fd536
commit f77425bfef
1 changed files with 6 additions and 6 deletions

View File

@ -41,8 +41,8 @@ type LogWriter struct {
func (w *LogWriter) Write(p []byte) (n int, err error) {
// 检查日志级别
if w.level > currentLevel {
return len(p), nil // 高于当前级别的日志直接忽略
if w.level < currentLevel {
return len(p), nil // 当前日志等级比配置的还低,不打印
}
_, file, line, ok := runtime.Caller(4)
@ -97,25 +97,25 @@ func UpdateLogLevel() {
// 辅助函数封装
func Info(format string, v ...interface{}) {
if currentLevel <= INFO {
if INFO >= currentLevel {
infoLogger.Printf(format, v...)
}
}
func Debug(format string, v ...interface{}) {
if currentLevel <= DEBUG {
if DEBUG >= currentLevel {
debugLogger.Printf(format, v...)
}
}
func Error(format string, v ...interface{}) {
if currentLevel <= ERROR {
if ERROR >= currentLevel {
errorLogger.Printf(format, v...)
}
}
func Warn(format string, v ...interface{}) {
if currentLevel <= WARN {
if WARN >= currentLevel {
warningLogger.Printf(format, v...)
}
}