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:
Kévin Dunglas
2024-09-13 19:16:37 +02:00
committed by GitHub
parent 21f9c20a04
commit f4bf4e0097
30 changed files with 599 additions and 282 deletions

View File

@ -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()