mirror of
https://github.com/minio/minio.git
synced 2024-12-24 22:25:54 -05:00
log: Use error log type instead of Application/MinIO type (#18930)
* log: Use error log type instead of Application/MinIO type Also bump github.com/shirou/gopsutil version to address cross compilation issues. * Apply suggestions from code review Co-authored-by: Aditya Manthramurthy <donatello@users.noreply.github.com> --------- Co-authored-by: Anis Eleuch <anis@min.io> Co-authored-by: Harshavardhana <harsha@minio.io> Co-authored-by: Aditya Manthramurthy <donatello@users.noreply.github.com>
This commit is contained in:
parent
59cc3e93d6
commit
6fd63e920a
@ -58,7 +58,7 @@ func (a adminAPIHandlers) DelConfigKVHandler(w http.ResponseWriter, r *http.Requ
|
|||||||
password := cred.SecretKey
|
password := cred.SecretKey
|
||||||
kvBytes, err := madmin.DecryptData(password, io.LimitReader(r.Body, r.ContentLength))
|
kvBytes, err := madmin.DecryptData(password, io.LimitReader(r.Body, r.ContentLength))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.LogIf(ctx, err, logger.Application)
|
logger.LogIf(ctx, err, logger.ErrorKind)
|
||||||
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrAdminConfigBadJSON), r.URL)
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrAdminConfigBadJSON), r.URL)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -162,7 +162,7 @@ func (a adminAPIHandlers) SetConfigKVHandler(w http.ResponseWriter, r *http.Requ
|
|||||||
password := cred.SecretKey
|
password := cred.SecretKey
|
||||||
kvBytes, err := madmin.DecryptData(password, io.LimitReader(r.Body, r.ContentLength))
|
kvBytes, err := madmin.DecryptData(password, io.LimitReader(r.Body, r.ContentLength))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.LogIf(ctx, err, logger.Application)
|
logger.LogIf(ctx, err, logger.ErrorKind)
|
||||||
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrAdminConfigBadJSON), r.URL)
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrAdminConfigBadJSON), r.URL)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -443,7 +443,7 @@ func (a adminAPIHandlers) SetConfigHandler(w http.ResponseWriter, r *http.Reques
|
|||||||
password := cred.SecretKey
|
password := cred.SecretKey
|
||||||
kvBytes, err := madmin.DecryptData(password, io.LimitReader(r.Body, r.ContentLength))
|
kvBytes, err := madmin.DecryptData(password, io.LimitReader(r.Body, r.ContentLength))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.LogIf(ctx, err, logger.Application)
|
logger.LogIf(ctx, err, logger.ErrorKind)
|
||||||
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrAdminConfigBadJSON), r.URL)
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrAdminConfigBadJSON), r.URL)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ func addOrUpdateIDPHandler(ctx context.Context, w http.ResponseWriter, r *http.R
|
|||||||
password := cred.SecretKey
|
password := cred.SecretKey
|
||||||
reqBytes, err := madmin.DecryptData(password, io.LimitReader(r.Body, r.ContentLength))
|
reqBytes, err := madmin.DecryptData(password, io.LimitReader(r.Body, r.ContentLength))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.LogIf(ctx, err, logger.Application)
|
logger.LogIf(ctx, err, logger.ErrorKind)
|
||||||
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrAdminConfigBadJSON), r.URL)
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrAdminConfigBadJSON), r.URL)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ func (a adminAPIHandlers) AttachDetachPolicyLDAP(w http.ResponseWriter, r *http.
|
|||||||
password := cred.SecretKey
|
password := cred.SecretKey
|
||||||
reqBytes, err := madmin.DecryptData(password, io.LimitReader(r.Body, r.ContentLength))
|
reqBytes, err := madmin.DecryptData(password, io.LimitReader(r.Body, r.ContentLength))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.LogIf(ctx, err, logger.Application)
|
logger.LogIf(ctx, err, logger.ErrorKind)
|
||||||
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrAdminConfigBadJSON), r.URL)
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrAdminConfigBadJSON), r.URL)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -451,7 +451,7 @@ func (a adminAPIHandlers) ServiceHandler(w http.ResponseWriter, r *http.Request)
|
|||||||
case madmin.ServiceActionUnfreeze:
|
case madmin.ServiceActionUnfreeze:
|
||||||
serviceSig = serviceUnFreeze
|
serviceSig = serviceUnFreeze
|
||||||
default:
|
default:
|
||||||
logger.LogIf(ctx, fmt.Errorf("Unrecognized service action %s requested", action), logger.Application)
|
logger.LogIf(ctx, fmt.Errorf("Unrecognized service action %s requested", action), logger.ErrorKind)
|
||||||
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrMalformedPOSTRequest), r.URL)
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrMalformedPOSTRequest), r.URL)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -534,7 +534,7 @@ func (a adminAPIHandlers) ServiceV2Handler(w http.ResponseWriter, r *http.Reques
|
|||||||
case madmin.ServiceActionUnfreeze:
|
case madmin.ServiceActionUnfreeze:
|
||||||
serviceSig = serviceUnFreeze
|
serviceSig = serviceUnFreeze
|
||||||
default:
|
default:
|
||||||
logger.LogIf(ctx, fmt.Errorf("Unrecognized service action %s requested", action), logger.Application)
|
logger.LogIf(ctx, fmt.Errorf("Unrecognized service action %s requested", action), logger.ErrorKind)
|
||||||
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrMalformedPOSTRequest), r.URL)
|
writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrMalformedPOSTRequest), r.URL)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -1239,7 +1239,7 @@ func extractHealInitParams(vars map[string]string, qParms url.Values, r io.Reade
|
|||||||
if hip.clientToken == "" {
|
if hip.clientToken == "" {
|
||||||
jerr := json.NewDecoder(r).Decode(&hip.hs)
|
jerr := json.NewDecoder(r).Decode(&hip.hs)
|
||||||
if jerr != nil {
|
if jerr != nil {
|
||||||
logger.LogIf(GlobalContext, jerr, logger.Application)
|
logger.LogIf(GlobalContext, jerr, logger.ErrorKind)
|
||||||
err = ErrRequestBodyParse
|
err = ErrRequestBodyParse
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -257,7 +257,7 @@ func getClaimsFromTokenWithSecret(token, secret string) (map[string]interface{},
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
// Base64 decoding fails, we should log to indicate
|
// Base64 decoding fails, we should log to indicate
|
||||||
// something is malforming the request sent by client.
|
// something is malforming the request sent by client.
|
||||||
logger.LogIf(GlobalContext, err, logger.Application)
|
logger.LogIf(GlobalContext, err, logger.ErrorKind)
|
||||||
return nil, errAuthentication
|
return nil, errAuthentication
|
||||||
}
|
}
|
||||||
claims.MapClaims[sessionPolicyNameExtracted] = string(spBytes)
|
claims.MapClaims[sessionPolicyNameExtracted] = string(spBytes)
|
||||||
@ -339,7 +339,7 @@ func checkRequestAuthTypeWithVID(ctx context.Context, r *http.Request, action po
|
|||||||
|
|
||||||
func authenticateRequest(ctx context.Context, r *http.Request, action policy.Action) (s3Err APIErrorCode) {
|
func authenticateRequest(ctx context.Context, r *http.Request, action policy.Action) (s3Err APIErrorCode) {
|
||||||
if logger.GetReqInfo(ctx) == nil {
|
if logger.GetReqInfo(ctx) == nil {
|
||||||
logger.LogIf(ctx, errors.New("unexpected context.Context does not have a logger.ReqInfo"), logger.Minio)
|
logger.LogIf(ctx, errors.New("unexpected context.Context does not have a logger.ReqInfo"), logger.ErrorKind)
|
||||||
return ErrAccessDenied
|
return ErrAccessDenied
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -378,7 +378,7 @@ func authenticateRequest(ctx context.Context, r *http.Request, action policy.Act
|
|||||||
// To extract region from XML in request body, get copy of request body.
|
// To extract region from XML in request body, get copy of request body.
|
||||||
payload, err := io.ReadAll(io.LimitReader(r.Body, maxLocationConstraintSize))
|
payload, err := io.ReadAll(io.LimitReader(r.Body, maxLocationConstraintSize))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.LogIf(ctx, err, logger.Application)
|
logger.LogIf(ctx, err, logger.ErrorKind)
|
||||||
return ErrMalformedXML
|
return ErrMalformedXML
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1034,7 +1034,7 @@ func getTLSConfig() (x509Certs []*x509.Certificate, manager *certs.Manager, secu
|
|||||||
}
|
}
|
||||||
if err = manager.AddCertificate(certFile, keyFile); err != nil {
|
if err = manager.AddCertificate(certFile, keyFile); err != nil {
|
||||||
err = fmt.Errorf("Unable to load TLS certificate '%s,%s': %w", certFile, keyFile, err)
|
err = fmt.Errorf("Unable to load TLS certificate '%s,%s': %w", certFile, keyFile, err)
|
||||||
logger.LogIf(GlobalContext, err, logger.Minio)
|
logger.LogIf(GlobalContext, err, logger.ErrorKind)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
secureConn = true
|
secureConn = true
|
||||||
|
@ -196,7 +196,7 @@ func (sys *HTTPConsoleLoggerSys) Send(ctx context.Context, entry interface{}) er
|
|||||||
sys.logBuf.Value = lg
|
sys.logBuf.Value = lg
|
||||||
sys.logBuf = sys.logBuf.Next()
|
sys.logBuf = sys.logBuf.Next()
|
||||||
sys.Unlock()
|
sys.Unlock()
|
||||||
err := sys.console.Send(entry, string(logger.All))
|
err := sys.console.Send(entry)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
atomic.AddInt64(&sys.failedMessages, 1)
|
atomic.AddInt64(&sys.failedMessages, 1)
|
||||||
}
|
}
|
||||||
|
@ -530,7 +530,7 @@ func hostResolveToLocalhost(endpoint Endpoint) bool {
|
|||||||
endpoint.Hostname(),
|
endpoint.Hostname(),
|
||||||
)
|
)
|
||||||
ctx := logger.SetReqInfo(GlobalContext, reqInfo)
|
ctx := logger.SetReqInfo(GlobalContext, reqInfo)
|
||||||
logger.LogOnceIf(ctx, err, endpoint.Hostname(), logger.Application)
|
logger.LogOnceIf(ctx, err, endpoint.Hostname(), logger.ErrorKind)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
var loopback int
|
var loopback int
|
||||||
@ -602,7 +602,7 @@ func (endpoints Endpoints) UpdateIsLocal() error {
|
|||||||
ctx := logger.SetReqInfo(GlobalContext,
|
ctx := logger.SetReqInfo(GlobalContext,
|
||||||
reqInfo)
|
reqInfo)
|
||||||
logger.LogOnceIf(ctx, fmt.Errorf("%s resolves to localhost in a containerized deployment, waiting for it to resolve to a valid IP",
|
logger.LogOnceIf(ctx, fmt.Errorf("%s resolves to localhost in a containerized deployment, waiting for it to resolve to a valid IP",
|
||||||
endpoints[i].Hostname()), endpoints[i].Hostname(), logger.Application)
|
endpoints[i].Hostname()), endpoints[i].Hostname(), logger.ErrorKind)
|
||||||
}
|
}
|
||||||
|
|
||||||
continue
|
continue
|
||||||
@ -631,7 +631,7 @@ func (endpoints Endpoints) UpdateIsLocal() error {
|
|||||||
))
|
))
|
||||||
ctx := logger.SetReqInfo(GlobalContext,
|
ctx := logger.SetReqInfo(GlobalContext,
|
||||||
reqInfo)
|
reqInfo)
|
||||||
logger.LogOnceIf(ctx, err, endpoints[i].Hostname(), logger.Application)
|
logger.LogOnceIf(ctx, err, endpoints[i].Hostname(), logger.ErrorKind)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
resolvedList[i] = true
|
resolvedList[i] = true
|
||||||
@ -796,7 +796,7 @@ func (p PoolEndpointList) UpdateIsLocal() error {
|
|||||||
ctx := logger.SetReqInfo(GlobalContext,
|
ctx := logger.SetReqInfo(GlobalContext,
|
||||||
reqInfo)
|
reqInfo)
|
||||||
logger.LogOnceIf(ctx, fmt.Errorf("%s resolves to localhost in a containerized deployment, waiting for it to resolve to a valid IP",
|
logger.LogOnceIf(ctx, fmt.Errorf("%s resolves to localhost in a containerized deployment, waiting for it to resolve to a valid IP",
|
||||||
endpoint.Hostname()), endpoint.Hostname(), logger.Application)
|
endpoint.Hostname()), endpoint.Hostname(), logger.ErrorKind)
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -824,7 +824,7 @@ func (p PoolEndpointList) UpdateIsLocal() error {
|
|||||||
))
|
))
|
||||||
ctx := logger.SetReqInfo(GlobalContext,
|
ctx := logger.SetReqInfo(GlobalContext,
|
||||||
reqInfo)
|
reqInfo)
|
||||||
logger.LogOnceIf(ctx, err, endpoint.Hostname(), logger.Application)
|
logger.LogOnceIf(ctx, err, endpoint.Hostname(), logger.ErrorKind)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
resolvedList[endpoint] = true
|
resolvedList[endpoint] = true
|
||||||
|
@ -583,7 +583,7 @@ func (er erasureObjects) PutObjectPart(ctx context.Context, bucket, object, uplo
|
|||||||
data := r.Reader
|
data := r.Reader
|
||||||
// Validate input data size and it can never be less than zero.
|
// Validate input data size and it can never be less than zero.
|
||||||
if data.Size() < -1 {
|
if data.Size() < -1 {
|
||||||
logger.LogIf(ctx, errInvalidArgument, logger.Application)
|
logger.LogIf(ctx, errInvalidArgument, logger.ErrorKind)
|
||||||
return pi, toObjectErr(errInvalidArgument)
|
return pi, toObjectErr(errInvalidArgument)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1094,7 +1094,7 @@ func (er erasureObjects) putMetacacheObject(ctx context.Context, key string, r *
|
|||||||
|
|
||||||
// Validate input data size and it can never be less than zero.
|
// Validate input data size and it can never be less than zero.
|
||||||
if data.Size() < -1 {
|
if data.Size() < -1 {
|
||||||
logger.LogIf(ctx, errInvalidArgument, logger.Application)
|
logger.LogIf(ctx, errInvalidArgument, logger.ErrorKind)
|
||||||
return ObjectInfo{}, toObjectErr(errInvalidArgument)
|
return ObjectInfo{}, toObjectErr(errInvalidArgument)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1281,7 +1281,7 @@ func (er erasureObjects) putObject(ctx context.Context, bucket string, object st
|
|||||||
|
|
||||||
// Validate input data size and it can never be less than -1.
|
// Validate input data size and it can never be less than -1.
|
||||||
if data.Size() < -1 {
|
if data.Size() < -1 {
|
||||||
logger.LogIf(ctx, errInvalidArgument, logger.Application)
|
logger.LogIf(ctx, errInvalidArgument, logger.ErrorKind)
|
||||||
return ObjectInfo{}, toObjectErr(errInvalidArgument)
|
return ObjectInfo{}, toObjectErr(errInvalidArgument)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ func writeSTSErrorResponse(ctx context.Context, w http.ResponseWriter, errCode S
|
|||||||
}
|
}
|
||||||
switch errCode {
|
switch errCode {
|
||||||
case ErrSTSInternalError, ErrSTSUpstreamError:
|
case ErrSTSInternalError, ErrSTSUpstreamError:
|
||||||
logger.LogIf(ctx, err, logger.Minio)
|
logger.LogIf(ctx, err, logger.ErrorKind)
|
||||||
}
|
}
|
||||||
encodedErrorResponse := encodeResponse(stsErrorResponse)
|
encodedErrorResponse := encodeResponse(stsErrorResponse)
|
||||||
writeResponse(w, stsErr.HTTPStatusCode, encodedErrorResponse, mimeXML)
|
writeResponse(w, stsErr.HTTPStatusCode, encodedErrorResponse, mimeXML)
|
||||||
|
@ -99,8 +99,8 @@ func TestMain(m *testing.M) {
|
|||||||
|
|
||||||
// Disable printing console messages during tests.
|
// Disable printing console messages during tests.
|
||||||
color.Output = io.Discard
|
color.Output = io.Discard
|
||||||
// Minimum is error logs for testing
|
// Disable Error logging in testing.
|
||||||
logger.MinimumLogLevel = logger.ErrorLvl
|
logger.DisableErrorLog = true
|
||||||
|
|
||||||
// Uncomment the following line to see trace logs during unit tests.
|
// Uncomment the following line to see trace logs during unit tests.
|
||||||
// logger.AddTarget(console.New())
|
// logger.AddTarget(console.New())
|
||||||
|
8
go.mod
8
go.mod
@ -51,10 +51,10 @@ require (
|
|||||||
github.com/minio/dperf v0.5.3
|
github.com/minio/dperf v0.5.3
|
||||||
github.com/minio/highwayhash v1.0.2
|
github.com/minio/highwayhash v1.0.2
|
||||||
github.com/minio/kes-go v0.2.0
|
github.com/minio/kes-go v0.2.0
|
||||||
github.com/minio/madmin-go/v3 v3.0.40
|
github.com/minio/madmin-go/v3 v3.0.43
|
||||||
github.com/minio/minio-go/v7 v7.0.66
|
github.com/minio/minio-go/v7 v7.0.66
|
||||||
github.com/minio/mux v1.9.0
|
github.com/minio/mux v1.9.0
|
||||||
github.com/minio/pkg/v2 v2.0.8
|
github.com/minio/pkg/v2 v2.0.9-0.20240130164631-ac3f1be23e94
|
||||||
github.com/minio/selfupdate v0.6.0
|
github.com/minio/selfupdate v0.6.0
|
||||||
github.com/minio/sha256-simd v1.0.1
|
github.com/minio/sha256-simd v1.0.1
|
||||||
github.com/minio/simdjson-go v0.4.5
|
github.com/minio/simdjson-go v0.4.5
|
||||||
@ -80,7 +80,7 @@ require (
|
|||||||
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475
|
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475
|
||||||
github.com/rs/cors v1.10.1
|
github.com/rs/cors v1.10.1
|
||||||
github.com/secure-io/sio-go v0.3.1
|
github.com/secure-io/sio-go v0.3.1
|
||||||
github.com/shirou/gopsutil/v3 v3.23.11
|
github.com/shirou/gopsutil/v3 v3.24.1
|
||||||
github.com/tidwall/gjson v1.17.0
|
github.com/tidwall/gjson v1.17.0
|
||||||
github.com/tinylib/msgp v1.1.9
|
github.com/tinylib/msgp v1.1.9
|
||||||
github.com/valyala/bytebufferpool v1.0.0
|
github.com/valyala/bytebufferpool v1.0.0
|
||||||
@ -196,7 +196,7 @@ require (
|
|||||||
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
|
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
|
||||||
github.com/minio/colorjson v1.0.6 // indirect
|
github.com/minio/colorjson v1.0.6 // indirect
|
||||||
github.com/minio/filepath v1.0.0 // indirect
|
github.com/minio/filepath v1.0.0 // indirect
|
||||||
github.com/minio/mc v0.0.0-20240111054932-d4305a5bf95e // indirect
|
github.com/minio/mc v0.0.0-20240129194012-12f446e1de57 // indirect
|
||||||
github.com/minio/md5-simd v1.1.2 // indirect
|
github.com/minio/md5-simd v1.1.2 // indirect
|
||||||
github.com/minio/websocket v1.6.0 // indirect
|
github.com/minio/websocket v1.6.0 // indirect
|
||||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||||
|
16
go.sum
16
go.sum
@ -443,10 +443,10 @@ github.com/minio/highwayhash v1.0.2 h1:Aak5U0nElisjDCfPSG79Tgzkn2gl66NxOMspRrKnA
|
|||||||
github.com/minio/highwayhash v1.0.2/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY=
|
github.com/minio/highwayhash v1.0.2/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY=
|
||||||
github.com/minio/kes-go v0.2.0 h1:HA33arq9s3MErbsj3PAXFVfFo4U4yw7lTKQ5kWFrpCA=
|
github.com/minio/kes-go v0.2.0 h1:HA33arq9s3MErbsj3PAXFVfFo4U4yw7lTKQ5kWFrpCA=
|
||||||
github.com/minio/kes-go v0.2.0/go.mod h1:VorHLaIYis9/MxAHAtXN4d8PUMNKhIxTIlvFt0hBOEo=
|
github.com/minio/kes-go v0.2.0/go.mod h1:VorHLaIYis9/MxAHAtXN4d8PUMNKhIxTIlvFt0hBOEo=
|
||||||
github.com/minio/madmin-go/v3 v3.0.40 h1:e4bfbRYgzv+Sl13ek6CM1la0PMLfxfgmKSLjBBDil0I=
|
github.com/minio/madmin-go/v3 v3.0.43 h1:AkniczVEkBErQ94MikyPINGoOjFWhuP8xH5KmFpAaO0=
|
||||||
github.com/minio/madmin-go/v3 v3.0.40/go.mod h1:4QN2NftLSV7MdlT50dkrenOMmNVHluxTvlqJou3hte8=
|
github.com/minio/madmin-go/v3 v3.0.43/go.mod h1:ZDF7kf5fhmxLhbGTqyq5efs4ao0v4eWf7nOuef/ljJs=
|
||||||
github.com/minio/mc v0.0.0-20240111054932-d4305a5bf95e h1:vKnv5aBTcAAnDGYeJW/SPieXCerp/7MIYxuEUYt7iOE=
|
github.com/minio/mc v0.0.0-20240129194012-12f446e1de57 h1:FO4a9XVuLcIS5s11efycWkBNrfIz4HtDQgUhR+xmLsQ=
|
||||||
github.com/minio/mc v0.0.0-20240111054932-d4305a5bf95e/go.mod h1:wFVJTmLJniMFDkcvPP0h/KvCxK+MiA2rc6q7KUefN28=
|
github.com/minio/mc v0.0.0-20240129194012-12f446e1de57/go.mod h1:MmDLdb7NWd/OYhcKcXKvwErq2GNa/Zq6xtTWuhdC4II=
|
||||||
github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
|
github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
|
||||||
github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM=
|
github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM=
|
||||||
github.com/minio/minio-go/v6 v6.0.46/go.mod h1:qD0lajrGW49lKZLtXKtCB4X/qkMf0a5tBvN2PaZg7Gg=
|
github.com/minio/minio-go/v6 v6.0.46/go.mod h1:qD0lajrGW49lKZLtXKtCB4X/qkMf0a5tBvN2PaZg7Gg=
|
||||||
@ -454,8 +454,8 @@ github.com/minio/minio-go/v7 v7.0.66 h1:bnTOXOHjOqv/gcMuiVbN9o2ngRItvqE774dG9nq0
|
|||||||
github.com/minio/minio-go/v7 v7.0.66/go.mod h1:DHAgmyQEGdW3Cif0UooKOyrT3Vxs82zNdV6tkKhRtbs=
|
github.com/minio/minio-go/v7 v7.0.66/go.mod h1:DHAgmyQEGdW3Cif0UooKOyrT3Vxs82zNdV6tkKhRtbs=
|
||||||
github.com/minio/mux v1.9.0 h1:dWafQFyEfGhJvK6AwLOt83bIG5bxKxKJnKMCi0XAaoA=
|
github.com/minio/mux v1.9.0 h1:dWafQFyEfGhJvK6AwLOt83bIG5bxKxKJnKMCi0XAaoA=
|
||||||
github.com/minio/mux v1.9.0/go.mod h1:1pAare17ZRL5GpmNL+9YmqHoWnLmMZF9C/ioUCfy0BQ=
|
github.com/minio/mux v1.9.0/go.mod h1:1pAare17ZRL5GpmNL+9YmqHoWnLmMZF9C/ioUCfy0BQ=
|
||||||
github.com/minio/pkg/v2 v2.0.8 h1:JuNWjELRaDSMZegeWxNcx5Lf7ZxqKAI5hjSgx1bLbKc=
|
github.com/minio/pkg/v2 v2.0.9-0.20240130164631-ac3f1be23e94 h1:nBZkkmq9HPfs2ZUDcRqPahe2js1mvMUR/7cBfW17Jik=
|
||||||
github.com/minio/pkg/v2 v2.0.8/go.mod h1:yayUTo82b0RK+e97hGb1naC787mOtUEyDs3SIcwSyHI=
|
github.com/minio/pkg/v2 v2.0.9-0.20240130164631-ac3f1be23e94/go.mod h1:yayUTo82b0RK+e97hGb1naC787mOtUEyDs3SIcwSyHI=
|
||||||
github.com/minio/selfupdate v0.6.0 h1:i76PgT0K5xO9+hjzKcacQtO7+MjJ4JKA8Ak8XQ9DDwU=
|
github.com/minio/selfupdate v0.6.0 h1:i76PgT0K5xO9+hjzKcacQtO7+MjJ4JKA8Ak8XQ9DDwU=
|
||||||
github.com/minio/selfupdate v0.6.0/go.mod h1:bO02GTIPCMQFTEvE5h4DjYB58bCoZ35XLeBf0buTDdM=
|
github.com/minio/selfupdate v0.6.0/go.mod h1:bO02GTIPCMQFTEvE5h4DjYB58bCoZ35XLeBf0buTDdM=
|
||||||
github.com/minio/sha256-simd v0.1.1/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM=
|
github.com/minio/sha256-simd v0.1.1/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM=
|
||||||
@ -606,8 +606,8 @@ github.com/safchain/ethtool v0.3.0/go.mod h1:SA9BwrgyAqNo7M+uaL6IYbxpm5wk3L7Mm6o
|
|||||||
github.com/scylladb/termtables v0.0.0-20191203121021-c4c0b6d42ff4/go.mod h1:C1a7PQSMz9NShzorzCiG2fk9+xuCgLkPeCvMHYR2OWg=
|
github.com/scylladb/termtables v0.0.0-20191203121021-c4c0b6d42ff4/go.mod h1:C1a7PQSMz9NShzorzCiG2fk9+xuCgLkPeCvMHYR2OWg=
|
||||||
github.com/secure-io/sio-go v0.3.1 h1:dNvY9awjabXTYGsTF1PiCySl9Ltofk9GA3VdWlo7rRc=
|
github.com/secure-io/sio-go v0.3.1 h1:dNvY9awjabXTYGsTF1PiCySl9Ltofk9GA3VdWlo7rRc=
|
||||||
github.com/secure-io/sio-go v0.3.1/go.mod h1:+xbkjDzPjwh4Axd07pRKSNriS9SCiYksWnZqdnfpQxs=
|
github.com/secure-io/sio-go v0.3.1/go.mod h1:+xbkjDzPjwh4Axd07pRKSNriS9SCiYksWnZqdnfpQxs=
|
||||||
github.com/shirou/gopsutil/v3 v3.23.11 h1:i3jP9NjCPUz7FiZKxlMnODZkdSIp2gnzfrvsu9CuWEQ=
|
github.com/shirou/gopsutil/v3 v3.24.1 h1:R3t6ondCEvmARp3wxODhXMTLC/klMa87h2PHUw5m7QI=
|
||||||
github.com/shirou/gopsutil/v3 v3.23.11/go.mod h1:1FrWgea594Jp7qmjHUUPlJDTPgcsb9mGnXDxavtikzM=
|
github.com/shirou/gopsutil/v3 v3.24.1/go.mod h1:UU7a2MSBQa+kW1uuDq8DeEBS8kmrnQwsv2b5O513rwU=
|
||||||
github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM=
|
github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM=
|
||||||
github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ=
|
github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ=
|
||||||
github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU=
|
github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU=
|
||||||
|
@ -49,8 +49,8 @@ var generateKeyTests = []struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGenerateKey(t *testing.T) {
|
func TestGenerateKey(t *testing.T) {
|
||||||
defer func(l logger.LogLevel) { logger.MinimumLogLevel = l }(logger.MinimumLogLevel)
|
defer func(l bool) { logger.DisableErrorLog = l }(logger.DisableErrorLog)
|
||||||
logger.MinimumLogLevel = logger.ErrorLvl
|
logger.DisableErrorLog = true
|
||||||
|
|
||||||
for i, test := range generateKeyTests {
|
for i, test := range generateKeyTests {
|
||||||
i, test := i, test
|
i, test := i, test
|
||||||
@ -75,8 +75,8 @@ var generateIVTests = []struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGenerateIV(t *testing.T) {
|
func TestGenerateIV(t *testing.T) {
|
||||||
defer func(l logger.LogLevel) { logger.MinimumLogLevel = l }(logger.MinimumLogLevel)
|
defer func(l bool) { logger.DisableErrorLog = l }(logger.DisableErrorLog)
|
||||||
logger.MinimumLogLevel = logger.ErrorLvl
|
logger.DisableErrorLog = true
|
||||||
|
|
||||||
for i, test := range generateIVTests {
|
for i, test := range generateIVTests {
|
||||||
i, test := i, test
|
i, test := i, test
|
||||||
|
@ -313,8 +313,8 @@ var s3CreateMetadataTests = []struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestS3CreateMetadata(t *testing.T) {
|
func TestS3CreateMetadata(t *testing.T) {
|
||||||
defer func(l logger.LogLevel) { logger.MinimumLogLevel = l }(logger.MinimumLogLevel)
|
defer func(l bool) { logger.DisableErrorLog = l }(logger.DisableErrorLog)
|
||||||
logger.MinimumLogLevel = logger.ErrorLvl
|
logger.DisableErrorLog = true
|
||||||
for i, test := range s3CreateMetadataTests {
|
for i, test := range s3CreateMetadataTests {
|
||||||
metadata := S3.CreateMetadata(nil, test.KeyID, test.SealedDataKey, test.SealedKey)
|
metadata := S3.CreateMetadata(nil, test.KeyID, test.SealedDataKey, test.SealedKey)
|
||||||
keyID, kmsKey, sealedKey, err := S3.ParseMetadata(metadata)
|
keyID, kmsKey, sealedKey, err := S3.ParseMetadata(metadata)
|
||||||
@ -358,8 +358,8 @@ var ssecCreateMetadataTests = []struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSSECCreateMetadata(t *testing.T) {
|
func TestSSECCreateMetadata(t *testing.T) {
|
||||||
defer func(l logger.LogLevel) { logger.MinimumLogLevel = l }(logger.MinimumLogLevel)
|
defer func(l bool) { logger.DisableErrorLog = l }(logger.DisableErrorLog)
|
||||||
logger.MinimumLogLevel = logger.ErrorLvl
|
logger.DisableErrorLog = true
|
||||||
for i, test := range ssecCreateMetadataTests {
|
for i, test := range ssecCreateMetadataTests {
|
||||||
metadata := SSEC.CreateMetadata(nil, test.SealedKey)
|
metadata := SSEC.CreateMetadata(nil, test.SealedKey)
|
||||||
sealedKey, err := SSEC.ParseMetadata(metadata)
|
sealedKey, err := SSEC.ParseMetadata(metadata)
|
||||||
|
@ -91,7 +91,7 @@ func (f fatalMsg) json(msg string, args ...interface{}) {
|
|||||||
message = fmt.Sprint(args...)
|
message = fmt.Sprint(args...)
|
||||||
}
|
}
|
||||||
logJSON, err := json.Marshal(&log.Entry{
|
logJSON, err := json.Marshal(&log.Entry{
|
||||||
Level: FatalLvl.String(),
|
Level: FatalKind,
|
||||||
Message: message,
|
Message: message,
|
||||||
Time: time.Now().UTC(),
|
Time: time.Now().UTC(),
|
||||||
Trace: &log.Trace{Message: message, Source: []string{getSource(6)}},
|
Trace: &log.Trace{Message: message, Source: []string{getSource(6)}},
|
||||||
@ -169,7 +169,7 @@ func (i infoMsg) json(msg string, args ...interface{}) {
|
|||||||
message = fmt.Sprint(args...)
|
message = fmt.Sprint(args...)
|
||||||
}
|
}
|
||||||
logJSON, err := json.Marshal(&log.Entry{
|
logJSON, err := json.Marshal(&log.Entry{
|
||||||
Level: InfoLvl.String(),
|
Level: InfoKind,
|
||||||
Message: message,
|
Message: message,
|
||||||
Time: time.Now().UTC(),
|
Time: time.Now().UTC(),
|
||||||
})
|
})
|
||||||
@ -201,7 +201,7 @@ func (i errorMsg) json(msg string, args ...interface{}) {
|
|||||||
message = fmt.Sprint(args...)
|
message = fmt.Sprint(args...)
|
||||||
}
|
}
|
||||||
logJSON, err := json.Marshal(&log.Entry{
|
logJSON, err := json.Marshal(&log.Entry{
|
||||||
Level: ErrorLvl.String(),
|
Level: ErrorKind,
|
||||||
Message: message,
|
Message: message,
|
||||||
Time: time.Now().UTC(),
|
Time: time.Now().UTC(),
|
||||||
Trace: &log.Trace{Message: message, Source: []string{getSource(6)}},
|
Trace: &log.Trace{Message: message, Source: []string{getSource(6)}},
|
||||||
@ -225,7 +225,7 @@ func (i errorMsg) pretty(msg string, args ...interface{}) {
|
|||||||
|
|
||||||
// Error :
|
// Error :
|
||||||
func Error(msg string, data ...interface{}) {
|
func Error(msg string, data ...interface{}) {
|
||||||
if MinimumLogLevel > ErrorLvl {
|
if DisableErrorLog {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
consoleLog(errorm, msg, data...)
|
consoleLog(errorm, msg, data...)
|
||||||
@ -233,7 +233,7 @@ func Error(msg string, data ...interface{}) {
|
|||||||
|
|
||||||
// Info :
|
// Info :
|
||||||
func Info(msg string, data ...interface{}) {
|
func Info(msg string, data ...interface{}) {
|
||||||
if MinimumLogLevel > InfoLvl {
|
if DisableErrorLog {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
consoleLog(info, msg, data...)
|
consoleLog(info, msg, data...)
|
||||||
|
@ -39,22 +39,18 @@ import (
|
|||||||
// HighwayHash key for logging in anonymous mode
|
// HighwayHash key for logging in anonymous mode
|
||||||
var magicHighwayHash256Key = []byte("\x4b\xe7\x34\xfa\x8e\x23\x8a\xcd\x26\x3e\x83\xe6\xbb\x96\x85\x52\x04\x0f\x93\x5d\xa3\x9f\x44\x14\x97\xe0\x9d\x13\x22\xde\x36\xa0")
|
var magicHighwayHash256Key = []byte("\x4b\xe7\x34\xfa\x8e\x23\x8a\xcd\x26\x3e\x83\xe6\xbb\x96\x85\x52\x04\x0f\x93\x5d\xa3\x9f\x44\x14\x97\xe0\x9d\x13\x22\xde\x36\xa0")
|
||||||
|
|
||||||
// LogLevel type
|
|
||||||
type LogLevel int8
|
|
||||||
|
|
||||||
// Enumerated level types
|
// Enumerated level types
|
||||||
const (
|
const (
|
||||||
InfoLvl LogLevel = iota + 1
|
// Log types errors
|
||||||
ErrorLvl
|
FatalKind = madmin.LogKindFatal
|
||||||
FatalLvl
|
WarningKind = madmin.LogKindWarning
|
||||||
|
ErrorKind = madmin.LogKindError
|
||||||
Application = madmin.LogKindApplication
|
EventKind = madmin.LogKindEvent
|
||||||
Minio = madmin.LogKindMinio
|
InfoKind = madmin.LogKindInfo
|
||||||
All = madmin.LogKindAll
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// MinimumLogLevel holds the minimum logging level to print - info by default
|
// DisableErrorLog avoids printing error/event/info kind of logs
|
||||||
var MinimumLogLevel = InfoLvl
|
var DisableErrorLog = false
|
||||||
|
|
||||||
var trimStrings []string
|
var trimStrings []string
|
||||||
|
|
||||||
@ -67,18 +63,6 @@ var matchingFuncNames = [...]string{
|
|||||||
// add more here ..
|
// add more here ..
|
||||||
}
|
}
|
||||||
|
|
||||||
func (level LogLevel) String() string {
|
|
||||||
switch level {
|
|
||||||
case InfoLvl:
|
|
||||||
return "INFO"
|
|
||||||
case ErrorLvl:
|
|
||||||
return "ERROR"
|
|
||||||
case FatalLvl:
|
|
||||||
return "FATAL"
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
// quietFlag: Hide startup messages if enabled
|
// quietFlag: Hide startup messages if enabled
|
||||||
// jsonFlag: Display in JSON format, if enabled
|
// jsonFlag: Display in JSON format, if enabled
|
||||||
var (
|
var (
|
||||||
@ -274,12 +258,13 @@ func LogIfNot(ctx context.Context, err error, ignored ...error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func errToEntry(ctx context.Context, err error, errKind ...interface{}) log.Entry {
|
func errToEntry(ctx context.Context, err error, errKind ...interface{}) log.Entry {
|
||||||
logKind := madmin.LogKindAll
|
logKind := madmin.LogKindError
|
||||||
if len(errKind) > 0 {
|
if len(errKind) > 0 {
|
||||||
if ek, ok := errKind[0].(madmin.LogKind); ok {
|
if ek, ok := errKind[0].(madmin.LogKind); ok {
|
||||||
logKind = ek
|
logKind = ek
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
req := GetReqInfo(ctx)
|
req := GetReqInfo(ctx)
|
||||||
|
|
||||||
if req == nil {
|
if req == nil {
|
||||||
@ -322,8 +307,7 @@ func errToEntry(ctx context.Context, err error, errKind ...interface{}) log.Entr
|
|||||||
|
|
||||||
entry := log.Entry{
|
entry := log.Entry{
|
||||||
DeploymentID: deploymentID,
|
DeploymentID: deploymentID,
|
||||||
Level: ErrorLvl.String(),
|
Level: logKind,
|
||||||
LogKind: logKind,
|
|
||||||
RemoteHost: req.RemoteHost,
|
RemoteHost: req.RemoteHost,
|
||||||
Host: req.Host,
|
Host: req.Host,
|
||||||
RequestID: req.RequestID,
|
RequestID: req.RequestID,
|
||||||
@ -359,7 +343,7 @@ func errToEntry(ctx context.Context, err error, errKind ...interface{}) log.Entr
|
|||||||
// consoleLogIf prints a detailed error message during
|
// consoleLogIf prints a detailed error message during
|
||||||
// the execution of the server.
|
// the execution of the server.
|
||||||
func consoleLogIf(ctx context.Context, err error, errKind ...interface{}) {
|
func consoleLogIf(ctx context.Context, err error, errKind ...interface{}) {
|
||||||
if MinimumLogLevel > ErrorLvl {
|
if DisableErrorLog {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -372,7 +356,7 @@ func consoleLogIf(ctx context.Context, err error, errKind ...interface{}) {
|
|||||||
// logIf prints a detailed error message during
|
// logIf prints a detailed error message during
|
||||||
// the execution of the server.
|
// the execution of the server.
|
||||||
func logIf(ctx context.Context, err error, errKind ...interface{}) {
|
func logIf(ctx context.Context, err error, errKind ...interface{}) {
|
||||||
if MinimumLogLevel > ErrorLvl {
|
if DisableErrorLog {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ func (c *Target) String() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Send log message 'e' to console
|
// Send log message 'e' to console
|
||||||
func (c *Target) Send(e interface{}, logKind string) error {
|
func (c *Target) Send(e interface{}) error {
|
||||||
entry, ok := e.(log.Entry)
|
entry, ok := e.(log.Entry)
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("Uexpected log entry structure %#v", e)
|
return fmt.Errorf("Uexpected log entry structure %#v", e)
|
||||||
|
Loading…
Reference in New Issue
Block a user