convert repeated error checks into single function in logger (#15387)

This commit is contained in:
jiuker
2022-07-26 08:53:03 +08:00
committed by GitHub
parent 426c902b87
commit 6b4f833a12
3 changed files with 11 additions and 34 deletions

View File

@@ -20,10 +20,8 @@ package logger
import (
"context"
"encoding/hex"
"errors"
"fmt"
"go/build"
"net/http"
"path/filepath"
"reflect"
"runtime"
@@ -255,18 +253,9 @@ func LogAlwaysIf(ctx context.Context, err error, errKind ...interface{}) {
// the execution of the server, if it is not an
// ignored error.
func LogIf(ctx context.Context, err error, errKind ...interface{}) {
if err == nil {
if logIgnoreError(err) {
return
}
if errors.Is(err, context.Canceled) {
return
}
if err.Error() == http.ErrServerClosed.Error() || err.Error() == "disk not found" {
return
}
logIf(ctx, err, errKind...)
}