Skip to content

Commit

Permalink
bring test case back
Browse files Browse the repository at this point in the history
  • Loading branch information
tac0turtle committed Oct 22, 2024
1 parent b9cc59b commit e3bb89a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions log/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
}

0 comments on commit e3bb89a

Please sign in to comment.