mirror of
https://github.com/minio/minio.git
synced 2025-11-07 21:02:58 -05:00
remove unnecessary logging and move to log once (#10798)
the current master logs way too much when a node is down, instead log once and move on.
This commit is contained in:
@@ -23,6 +23,7 @@ import (
|
||||
"fmt"
|
||||
"go/build"
|
||||
"hash"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"runtime"
|
||||
@@ -299,9 +300,17 @@ func LogIf(ctx context.Context, err error, errKind ...interface{}) {
|
||||
return
|
||||
}
|
||||
|
||||
if !errors.Is(err, context.Canceled) {
|
||||
logIf(ctx, err, errKind...)
|
||||
if errors.Is(err, context.Canceled) || errors.Is(err, http.ErrServerClosed) {
|
||||
return
|
||||
}
|
||||
|
||||
if e := errors.Unwrap(err); e != nil {
|
||||
if e.Error() == "disk not found" {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
logIf(ctx, err, errKind...)
|
||||
}
|
||||
|
||||
// logIf prints a detailed error message during
|
||||
|
||||
@@ -18,6 +18,8 @@ package logger
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"sync"
|
||||
|
||||
"time"
|
||||
@@ -77,5 +79,19 @@ var logOnce = newLogOnceType()
|
||||
// id is a unique identifier for related log messages, refer to cmd/notification.go
|
||||
// on how it is used.
|
||||
func LogOnceIf(ctx context.Context, err error, id interface{}, errKind ...interface{}) {
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
|
||||
if errors.Is(err, context.Canceled) || errors.Is(err, http.ErrServerClosed) {
|
||||
return
|
||||
}
|
||||
|
||||
if e := errors.Unwrap(err); e != nil {
|
||||
if e.Error() == "disk not found" {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
logOnce.logOnceIf(ctx, err, id, errKind...)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user