fix logger issues

This commit is contained in:
yanghao05
2023-01-30 11:23:04 +08:00
parent c7345f6252
commit f2c893709d
6 changed files with 194 additions and 7 deletions

View File

@@ -0,0 +1,23 @@
package log
import (
"strings"
"go.uber.org/zap/zapcore"
)
type LevelWriter struct {
Logger *Logger
Level zapcore.Level
}
func (w LevelWriter) Write(p []byte) (n int, err error) {
str := strings.TrimSpace(string(p))
switch w.Level {
case zapcore.InfoLevel:
Info(str)
case zapcore.ErrorLevel:
Error(str)
}
return len(p), nil
}