mirror of
https://github.com/caddyserver/caddy.git
synced 2025-05-28 22:55:50 +08:00
perf: use zap's Check() to prevent useless allocs (#6560)
* perf: use zap's Check() to prevent useless allocs * fix * fix * fix * fix * restore previous replacer behavior * fix linter
This commit is contained in:
@ -40,6 +40,7 @@ import (
|
||||
"time"
|
||||
|
||||
"go.uber.org/zap"
|
||||
"go.uber.org/zap/zapcore"
|
||||
)
|
||||
|
||||
// FCGIListenSockFileno describes listen socket file number.
|
||||
@ -184,10 +185,13 @@ func (f clientCloser) Close() error {
|
||||
return f.rwc.Close()
|
||||
}
|
||||
|
||||
logLevel := zapcore.WarnLevel
|
||||
if f.status >= 400 {
|
||||
f.logger.Error("stderr", zap.ByteString("body", stderr))
|
||||
} else {
|
||||
f.logger.Warn("stderr", zap.ByteString("body", stderr))
|
||||
logLevel = zapcore.ErrorLevel
|
||||
}
|
||||
|
||||
if c := f.logger.Check(logLevel, "stderr"); c != nil {
|
||||
c.Write(zap.ByteString("body", stderr))
|
||||
}
|
||||
|
||||
return f.rwc.Close()
|
||||
|
Reference in New Issue
Block a user