diff --git a/core/logger/internal/colortest/prettyconsole_test.go b/core/logger/internal/colortest/prettyconsole_test.go index 22ca79d57d9..fa2ad055a98 100644 --- a/core/logger/internal/colortest/prettyconsole_test.go +++ b/core/logger/internal/colortest/prettyconsole_test.go @@ -3,8 +3,9 @@ package colortest import ( "testing" - "github.com/smartcontractkit/chainlink/core/logger" "github.com/stretchr/testify/assert" + + "github.com/smartcontractkit/chainlink/core/logger" ) func init() { @@ -19,24 +20,48 @@ func TestPrettyConsole_Write(t *testing.T) { wantError bool }{ { - "headline", - `{"ts":1523537728.7260377, "level":"info", "msg":"top level"}`, - "2018-04-12T12:55:28Z \x1b[37m[INFO] \x1b[0mtop level \x1b[34m\x1b[0m \n", + "debug", + `{"ts":1523537728, "level":"debug", "msg":"top level", "details":"nuances"}`, + "2018-04-12T12:55:28Z \x1b[32m[DEBUG] \x1b[0mtop level \x1b[34m\x1b[0m \x1b[32mdetails\x1b[0m=nuances \n", false, }, { - "details", - `{"ts":1523537728, "level":"debug", "msg":"top level", "details":"nuances"}`, - "2018-04-12T12:55:28Z \x1b[32m[DEBUG] \x1b[0mtop level \x1b[34m\x1b[0m \x1b[32mdetails\x1b[0m=nuances \n", + "info", + `{"ts":1523537728.7260377, "level":"info", "msg":"top level"}`, + "2018-04-12T12:55:28Z \x1b[37m[INFO] \x1b[0mtop level \x1b[34m\x1b[0m \n", false, }, { - "blacklist", + "warn", `{"ts":1523537728, "level":"warn", "msg":"top level", "hash":"nuances"}`, "2018-04-12T12:55:28Z \x1b[33m[WARN] \x1b[0mtop level \x1b[34m\x1b[0m \n", false, }, - {"error", `{"broken":}`, `{}`, true}, + { + "error", + `{"ts":1523537728, "level":"error", "msg":"top level", "hash":"nuances"}`, + "2018-04-12T12:55:28Z \x1b[31m[ERROR] \x1b[0mtop level \x1b[34m\x1b[0m \n", + false, + }, + { + "critical", + `{"ts":1523537728, "level":"crit", "msg":"top level", "hash":"nuances"}`, + "2018-04-12T12:55:28Z \x1b[91m[CRIT] \x1b[0mtop level \x1b[34m\x1b[0m \n", + false, + }, + { + "panic", + `{"ts":1523537728, "level":"panic", "msg":"top level", "hash":"nuances"}`, + "2018-04-12T12:55:28Z \x1b[91m[PANIC] \x1b[0mtop level \x1b[34m\x1b[0m \n", + false, + }, + { + "fatal", + `{"ts":1523537728, "level":"fatal", "msg":"top level", "hash":"nuances"}`, + "2018-04-12T12:55:28Z \x1b[91m[FATAL] \x1b[0mtop level \x1b[34m\x1b[0m \n", + false, + }, + {"broken", `{"broken":}`, `{}`, true}, } for _, tt := range tests { @@ -48,6 +73,7 @@ func TestPrettyConsole_Write(t *testing.T) { if tt.wantError { assert.Error(t, err) } else { + t.Log(tr.Written) assert.Equal(t, tt.want, tr.Written) } }) diff --git a/core/logger/prettyconsole.go b/core/logger/prettyconsole.go index 1fabeffd187..69427f74715 100644 --- a/core/logger/prettyconsole.go +++ b/core/logger/prettyconsole.go @@ -20,8 +20,9 @@ var levelColors = map[string]func(...interface{}) string{ "info": color.New(color.FgWhite).SprintFunc(), "warn": color.New(color.FgYellow).SprintFunc(), "error": color.New(color.FgRed).SprintFunc(), - "panic": color.New(color.FgRed).SprintFunc(), - "fatal": color.New(color.FgRed).SprintFunc(), + "panic": color.New(color.FgHiRed).SprintFunc(), + "crit": color.New(color.FgHiRed).SprintFunc(), + "fatal": color.New(color.FgHiRed).SprintFunc(), } var blue = color.New(color.FgBlue).SprintFunc() diff --git a/core/logger/zap.go b/core/logger/zap.go index 6c844c072a8..01bc85dfb00 100644 --- a/core/logger/zap.go +++ b/core/logger/zap.go @@ -112,13 +112,7 @@ func makeEncoderConfig(cfg Config) zapcore.EncoderConfig { encoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder } - encoderConfig.EncodeLevel = func(l zapcore.Level, enc zapcore.PrimitiveArrayEncoder) { - if l == zapcore.DPanicLevel { - enc.AppendString("crit") - } else { - zapcore.LowercaseLevelEncoder(l, enc) - } - } + encoderConfig.EncodeLevel = encodeLevel return encoderConfig }