mirror of
https://github.com/caddyserver/caddy.git
synced 2025-10-19 15:53:17 +00: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:
parent
21f9c20a04
commit
f4bf4e0097
30 changed files with 599 additions and 282 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue