From c7a33dc5de7efe87c53ee9598ab7b73a508f0be7 Mon Sep 17 00:00:00 2001 From: Giedrius Dubinskas Date: Mon, 2 Oct 2017 19:38:29 +0300 Subject: [PATCH] Add Trace level logging --- exported.go | 4 ++-- logrus.go | 3 ++- logrus_test.go | 9 +++++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/exported.go b/exported.go index fb261aa..b9f1c9d 100644 --- a/exported.go +++ b/exported.go @@ -122,7 +122,7 @@ func Fatal(args ...interface{}) { std.Fatal(args...) } -// Tracef logs a message at level Debug on the standard logger. +// Tracef logs a message at level Trace on the standard logger. func Tracef(format string, args ...interface{}) { std.Tracef(format, args...) } @@ -167,7 +167,7 @@ func Fatalf(format string, args ...interface{}) { std.Fatalf(format, args...) } -// Traceln logs a message at level Debug on the standard logger. +// Traceln logs a message at level Trace on the standard logger. func Traceln(args ...interface{}) { std.Traceln(args...) } diff --git a/logrus.go b/logrus.go index 601d5e0..d657c41 100644 --- a/logrus.go +++ b/logrus.go @@ -87,7 +87,8 @@ const ( InfoLevel // DebugLevel level. Usually only enabled when debugging. Very verbose logging. DebugLevel - // TraceLevel level. Usually only enabled when debugging. Very verbose logging. Usually reserved for message traces + // TraceLevel level. Usually only enabled when debugging. Very verbose logging. + // Usually reserved for message traces. TraceLevel ) diff --git a/logrus_test.go b/logrus_test.go index 97d15d7..210feef 100644 --- a/logrus_test.go +++ b/logrus_test.go @@ -303,6 +303,7 @@ func TestDoubleLoggingDoesntPrefixPreviousFields(t *testing.T) { } func TestConvertLevelToString(t *testing.T) { + assert.Equal(t, "trace", TraceLevel.String()) assert.Equal(t, "debug", DebugLevel.String()) assert.Equal(t, "info", InfoLevel.String()) assert.Equal(t, "warning", WarnLevel.String()) @@ -368,6 +369,14 @@ func TestParseLevel(t *testing.T) { assert.Nil(t, err) assert.Equal(t, DebugLevel, l) + l, err = ParseLevel("trace") + assert.Nil(t, err) + assert.Equal(t, TraceLevel, l) + + l, err = ParseLevel("TRACE") + assert.Nil(t, err) + assert.Equal(t, TraceLevel, l) + l, err = ParseLevel("invalid") assert.Equal(t, "not a valid logrus Level: \"invalid\"", err.Error()) }