diff --git a/log/logger_test.go b/log/logger_test.go index 3a00e41748c9..752026a25bd8 100644 --- a/log/logger_test.go +++ b/log/logger_test.go @@ -43,3 +43,19 @@ func TestLoggerOptionHooks(t *testing.T) { t.Fatalf("expected hello world, got: %s", buf.String()) } } + +func TestLoggerOptionStackTrace(t *testing.T) { + buf := new(bytes.Buffer) + logger := log.NewLogger(buf, log.TraceOption(true), log.ColorOption(false)) + logger.Error("this log should be displayed", "error", inner()) + if strings.Count(buf.String(), "logger_test.go") != 1 { + t.Fatalf("stack trace not found, got: %s", buf.String()) + } + buf.Reset() + + logger = log.NewLogger(buf, log.TraceOption(false), log.ColorOption(false)) + logger.Error("this log should be displayed", "error", inner()) + if strings.Count(buf.String(), "logger_test.go") > 0 { + t.Fatalf("stack trace found, got: %s", buf.String()) + } +}