Skip to content

Commit

Permalink
Strengthen TestLoggerWith to handle chained Withs (#1328)
Browse files Browse the repository at this point in the history
Strengthen the cross talk tests to cover the case of chained Withs,
creating three levels of logger hierarchy.

This will be used to harden against possible regressions in a proposed
optimisation in #1319.
  • Loading branch information
jquirke authored Aug 18, 2023
1 parent 02ebf0f commit d2aeb27
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,13 @@ func TestLoggerWith(t *testing.T) {
// shouldn't stomp on each other's fields or affect the parent's fields.
logger.With(String("one", "two")).Info("")
logger.With(String("three", "four")).Info("")
logger.With(String("five", "six")).With(String("seven", "eight")).Info("")
logger.Info("")

assert.Equal(t, []observer.LoggedEntry{
{Context: []Field{Int("foo", 42), String("one", "two")}},
{Context: []Field{Int("foo", 42), String("three", "four")}},
{Context: []Field{Int("foo", 42), String("five", "six"), String("seven", "eight")}},
{Context: []Field{Int("foo", 42)}},
}, logs.AllUntimed(), "Unexpected cross-talk between child loggers.")
})
Expand Down

0 comments on commit d2aeb27

Please sign in to comment.