From 97ad06697ff0f88771ff1fbf2e9922a2ba54a198 Mon Sep 17 00:00:00 2001 From: Morgen Peschke Date: Tue, 25 Jun 2024 15:12:31 -0700 Subject: [PATCH] Add test explicitly demonstrating MDC behavior --- .../slf4j/internal/Slf4jLoggerInternalSuite.scala | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/slf4j/src/test/scala/org/typelevel/log4cats/slf4j/internal/Slf4jLoggerInternalSuite.scala b/slf4j/src/test/scala/org/typelevel/log4cats/slf4j/internal/Slf4jLoggerInternalSuite.scala index db09ca75..976dec24 100644 --- a/slf4j/src/test/scala/org/typelevel/log4cats/slf4j/internal/Slf4jLoggerInternalSuite.scala +++ b/slf4j/src/test/scala/org/typelevel/log4cats/slf4j/internal/Slf4jLoggerInternalSuite.scala @@ -141,6 +141,19 @@ class Slf4jLoggerInternalSuite extends CatsEffectSuite { ) } + testLoggerFixture().test("Slf4jLoggerInternal ignores(?) values already in the MDC") { testLogger => + IO.delay(MDC.put("baz", "bar")) >> + Slf4jLogger.getLoggerFromSlf4j[IO](testLogger).info(Map("foo" -> "bar"))("A log went here") >> + IO(testLogger.logs()) + .map(toDeferredLogs) + .assertEquals( + List( + DeferredLogMessage.info(Map("foo" -> "bar"), none, () => "A log went here") + ), + clue("Context should not include baz->bar") + ) + } + testLoggerFixture( traceEnabled = false, debugEnabled = false,