From ec6df50c44492d5360e526d5e0d1bccbbe02dff7 Mon Sep 17 00:00:00 2001 From: Erik van Oosten Date: Sat, 28 Oct 2023 10:45:00 +0200 Subject: [PATCH] Prevent double logging in tests (#1088) --- zio-kafka-test/src/test/resources/logback.xml | 4 ++++ .../src/test/scala/zio/kafka/ZIOSpecDefaultSlf4j.scala | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/zio-kafka-test/src/test/resources/logback.xml b/zio-kafka-test/src/test/resources/logback.xml index 3132d07e4..59861dd6b 100644 --- a/zio-kafka-test/src/test/resources/logback.xml +++ b/zio-kafka-test/src/test/resources/logback.xml @@ -14,6 +14,10 @@ + + + + diff --git a/zio-kafka-test/src/test/scala/zio/kafka/ZIOSpecDefaultSlf4j.scala b/zio-kafka-test/src/test/scala/zio/kafka/ZIOSpecDefaultSlf4j.scala index 5b753cb48..564c07fb8 100644 --- a/zio-kafka-test/src/test/scala/zio/kafka/ZIOSpecDefaultSlf4j.scala +++ b/zio-kafka-test/src/test/scala/zio/kafka/ZIOSpecDefaultSlf4j.scala @@ -11,7 +11,9 @@ import zio.test.{ TestAspect, TestAspectAtLeastR, TestEnvironment, ZIOSpecDefaul */ abstract class ZIOSpecDefaultSlf4j extends ZIOSpecDefault { + private val loggerLayer = SLF4J.slf4j + override def aspects: Chunk[TestAspectAtLeastR[TestEnvironment]] = - super.aspects :+ TestAspect.fromLayer(zio.Runtime.removeDefaultLoggers >>> SLF4J.slf4j) + super.aspects :+ TestAspect.fromLayer(zio.Runtime.removeDefaultLoggers >>> loggerLayer) }