mirror of
https://github.com/minio/minio.git
synced 2025-11-07 12:52:58 -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:
@@ -39,22 +39,18 @@ import (
|
||||
// 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")
|
||||
|
||||
// LogLevel type
|
||||
type LogLevel int8
|
||||
|
||||
// Enumerated level types
|
||||
const (
|
||||
InfoLvl LogLevel = iota + 1
|
||||
ErrorLvl
|
||||
FatalLvl
|
||||
|
||||
Application = madmin.LogKindApplication
|
||||
Minio = madmin.LogKindMinio
|
||||
All = madmin.LogKindAll
|
||||
// Log types errors
|
||||
FatalKind = madmin.LogKindFatal
|
||||
WarningKind = madmin.LogKindWarning
|
||||
ErrorKind = madmin.LogKindError
|
||||
EventKind = madmin.LogKindEvent
|
||||
InfoKind = madmin.LogKindInfo
|
||||
)
|
||||
|
||||
// MinimumLogLevel holds the minimum logging level to print - info by default
|
||||
var MinimumLogLevel = InfoLvl
|
||||
// DisableErrorLog avoids printing error/event/info kind of logs
|
||||
var DisableErrorLog = false
|
||||
|
||||
var trimStrings []string
|
||||
|
||||
@@ -67,18 +63,6 @@ var matchingFuncNames = [...]string{
|
||||
// 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
|
||||
// jsonFlag: Display in JSON format, if enabled
|
||||
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 {
|
||||
logKind := madmin.LogKindAll
|
||||
logKind := madmin.LogKindError
|
||||
if len(errKind) > 0 {
|
||||
if ek, ok := errKind[0].(madmin.LogKind); ok {
|
||||
logKind = ek
|
||||
}
|
||||
}
|
||||
|
||||
req := GetReqInfo(ctx)
|
||||
|
||||
if req == nil {
|
||||
@@ -322,8 +307,7 @@ func errToEntry(ctx context.Context, err error, errKind ...interface{}) log.Entr
|
||||
|
||||
entry := log.Entry{
|
||||
DeploymentID: deploymentID,
|
||||
Level: ErrorLvl.String(),
|
||||
LogKind: logKind,
|
||||
Level: logKind,
|
||||
RemoteHost: req.RemoteHost,
|
||||
Host: req.Host,
|
||||
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
|
||||
// the execution of the server.
|
||||
func consoleLogIf(ctx context.Context, err error, errKind ...interface{}) {
|
||||
if MinimumLogLevel > ErrorLvl {
|
||||
if DisableErrorLog {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -372,7 +356,7 @@ func consoleLogIf(ctx context.Context, err error, errKind ...interface{}) {
|
||||
// logIf prints a detailed error message during
|
||||
// the execution of the server.
|
||||
func logIf(ctx context.Context, err error, errKind ...interface{}) {
|
||||
if MinimumLogLevel > ErrorLvl {
|
||||
if DisableErrorLog {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user