MM-48345: Fix Critical level logging (#21952)
Critical wasn't added in the StdLevels slice and due to that mlog.Critical wasn't printing anything. This was a complete blindspot that was missed. We have removed all references to mlog.Critical in the codebase and pointed Critical to be Fatal in the library. In v8, we will remove Critical altogether. ```release-note Servers with an encrypted key will throw an error during startup now. ```
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
1353ebc3ab
Коммит
6ad1861535
@@ -113,13 +113,10 @@ func Error(msg string, fields ...Field) {
|
||||
|
||||
// Convenience method equivalent to calling `Log` with the `Critical` level.
|
||||
// DEPRECATED: Either use Error or Fatal.
|
||||
// Critical level isn't added in mlog/levels.go:StdAll so calling this doesn't
|
||||
// really work. For now we just call Fatal to atleast print something.
|
||||
func Critical(msg string, fields ...Field) {
|
||||
logger := getGlobalLogger()
|
||||
if logger == nil {
|
||||
defaultLog(LvlCritical, msg, fields...)
|
||||
return
|
||||
}
|
||||
logger.Critical(msg, fields...)
|
||||
Fatal(msg, fields...)
|
||||
}
|
||||
|
||||
func Fatal(msg string, fields ...Field) {
|
||||
|
||||
@@ -24,7 +24,6 @@ func TestLoggingBeforeInitialized(t *testing.T) {
|
||||
mlog.Debug("debug log")
|
||||
mlog.Warn("warning log")
|
||||
mlog.Error("error log")
|
||||
mlog.Critical("critical log")
|
||||
})
|
||||
}
|
||||
|
||||
@@ -40,14 +39,13 @@ func TestLoggingAfterInitialized(t *testing.T) {
|
||||
Type: "file",
|
||||
Format: "json",
|
||||
FormatOptions: json.RawMessage(`{"enable_caller":true}`),
|
||||
Levels: []mlog.Level{mlog.LvlCritical, mlog.LvlError, mlog.LvlWarn, mlog.LvlInfo, mlog.LvlDebug},
|
||||
Levels: []mlog.Level{mlog.LvlError, mlog.LvlWarn, mlog.LvlInfo, mlog.LvlDebug},
|
||||
},
|
||||
[]string{
|
||||
`{"timestamp":0,"level":"debug","msg":"real debug log","caller":"mlog/global_test.go:0"}`,
|
||||
`{"timestamp":0,"level":"info","msg":"real info log","caller":"mlog/global_test.go:0"}`,
|
||||
`{"timestamp":0,"level":"warn","msg":"real warning log","caller":"mlog/global_test.go:0"}`,
|
||||
`{"timestamp":0,"level":"error","msg":"real error log","caller":"mlog/global_test.go:0"}`,
|
||||
`{"timestamp":0,"level":"critical","msg":"real critical log","caller":"mlog/global_test.go:0"}`,
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -56,11 +54,10 @@ func TestLoggingAfterInitialized(t *testing.T) {
|
||||
Type: "file",
|
||||
Format: "json",
|
||||
FormatOptions: json.RawMessage(`{"enable_caller":true}`),
|
||||
Levels: []mlog.Level{mlog.LvlCritical, mlog.LvlError},
|
||||
Levels: []mlog.Level{mlog.LvlError},
|
||||
},
|
||||
[]string{
|
||||
`{"timestamp":0,"level":"error","msg":"real error log","caller":"mlog/global_test.go:0"}`,
|
||||
`{"timestamp":0,"level":"critical","msg":"real critical log","caller":"mlog/global_test.go:0"}`,
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -69,14 +66,13 @@ func TestLoggingAfterInitialized(t *testing.T) {
|
||||
Type: "file",
|
||||
Format: "plain",
|
||||
FormatOptions: json.RawMessage(`{"delim":" | ", "enable_caller":true}`),
|
||||
Levels: []mlog.Level{mlog.LvlCritical, mlog.LvlError, mlog.LvlWarn, mlog.LvlInfo, mlog.LvlDebug},
|
||||
Levels: []mlog.Level{mlog.LvlError, mlog.LvlWarn, mlog.LvlInfo, mlog.LvlDebug},
|
||||
},
|
||||
[]string{
|
||||
`debug | TIME | real debug log | caller="mlog/global_test.go:0"`,
|
||||
`info | TIME | real info log | caller="mlog/global_test.go:0"`,
|
||||
`warn | TIME | real warning log | caller="mlog/global_test.go:0"`,
|
||||
`error | TIME | real error log | caller="mlog/global_test.go:0"`,
|
||||
`critical | TIME | real critical log | caller="mlog/global_test.go:0"`,
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -85,11 +81,10 @@ func TestLoggingAfterInitialized(t *testing.T) {
|
||||
Type: "file",
|
||||
Format: "plain",
|
||||
FormatOptions: json.RawMessage(`{"delim":" | ", "enable_caller":true}`),
|
||||
Levels: []mlog.Level{mlog.LvlCritical, mlog.LvlError},
|
||||
Levels: []mlog.Level{mlog.LvlError},
|
||||
},
|
||||
[]string{
|
||||
`error | TIME | real error log | caller="mlog/global_test.go:0"`,
|
||||
`critical | TIME | real critical log | caller="mlog/global_test.go:0"`,
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -116,7 +111,6 @@ func TestLoggingAfterInitialized(t *testing.T) {
|
||||
mlog.Info("real info log")
|
||||
mlog.Warn("real warning log")
|
||||
mlog.Error("real error log")
|
||||
mlog.Critical("real critical log")
|
||||
|
||||
logger.Shutdown()
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user