From 82dfb955f51777eb7bee69710394dc47b8232f34 Mon Sep 17 00:00:00 2001 From: wangcong <497272486@qq.com> Date: Thu, 21 Jul 2022 21:25:42 +0800 Subject: [PATCH] fix(contrib): add logrus fatal level (#2222) --- contrib/log/logrus/logrus.go | 2 ++ contrib/log/logrus/logrus_test.go | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/contrib/log/logrus/logrus.go b/contrib/log/logrus/logrus.go index 748055e5f..b08ba6e13 100644 --- a/contrib/log/logrus/logrus.go +++ b/contrib/log/logrus/logrus.go @@ -33,6 +33,8 @@ func (l *Logger) Log(level log.Level, keyvals ...interface{}) (err error) { logrusLevel = logrus.WarnLevel case log.LevelError: logrusLevel = logrus.ErrorLevel + case log.LevelFatal: + logrusLevel = logrus.FatalLevel default: logrusLevel = logrus.DebugLevel } diff --git a/contrib/log/logrus/logrus_test.go b/contrib/log/logrus/logrus_test.go index 5a6e69aeb..3dcd6e64f 100644 --- a/contrib/log/logrus/logrus_test.go +++ b/contrib/log/logrus/logrus_test.go @@ -32,6 +32,13 @@ func TestLoggerLog(t *testing.T) { kvs: []interface{}{"case", "level unmatch", "msg", "1"}, want: "", }, + "fatal level": { + level: logrus.InfoLevel, + formatter: &logrus.JSONFormatter{}, + logLevel: log.LevelFatal, + kvs: []interface{}{"case", "json format", "msg", "1"}, + want: `{"case":"json format","level":"fatal","msg":"1"`, + }, "no tags": { level: logrus.InfoLevel, formatter: &logrus.JSONFormatter{},