diff --git a/slf4j-bridge/src/main/scala/zio/logging/slf4j/bridge/Slf4jBridge.scala b/slf4j-bridge/src/main/scala/zio/logging/slf4j/bridge/Slf4jBridge.scala index a9d35406..463dde8b 100644 --- a/slf4j-bridge/src/main/scala/zio/logging/slf4j/bridge/Slf4jBridge.scala +++ b/slf4j-bridge/src/main/scala/zio/logging/slf4j/bridge/Slf4jBridge.scala @@ -37,9 +37,9 @@ object Slf4jBridge { ZLayer { for { runtime <- ZIO.runtime[Any] - _ <- initLock.withPermit { - ZIO.succeed(ZioLoggerFactory.initialize(new ZioLoggerRuntime(runtime))) - } + _ <- initLock.withPermit { + ZIO.succeed(ZioLoggerFactory.initialize(new ZioLoggerRuntime(runtime))) + } } yield () } } diff --git a/slf4j-bridge/src/test/scala/zio/logging/slf4j/bridge/Slf4jBridgeSpec.scala b/slf4j-bridge/src/test/scala/zio/logging/slf4j/bridge/Slf4jBridgeSpec.scala index 4c725cff..d03247d8 100644 --- a/slf4j-bridge/src/test/scala/zio/logging/slf4j/bridge/Slf4jBridgeSpec.scala +++ b/slf4j-bridge/src/test/scala/zio/logging/slf4j/bridge/Slf4jBridgeSpec.scala @@ -8,12 +8,12 @@ import zio.{ Cause, Chunk, LogLevel, ZIO, ZIOAspect } object Slf4jBridgeSpec extends ZIOSpecDefault { final case class LogEntry( - span: List[String], - level: LogLevel, - annotations: Map[String, String], - message: String, - cause: Cause[Any] - ) + span: List[String], + level: LogLevel, + annotations: Map[String, String], + message: String, + cause: Cause[Any] + ) override def spec = suite("Slf4jBridge")( @@ -41,25 +41,25 @@ object Slf4jBridgeSpec extends ZIOSpecDefault { val testFailure = new RuntimeException("test error") for { _ <- (for { - logger <- ZIO.attempt(org.slf4j.LoggerFactory.getLogger("test.logger")) - _ <- ZIO.logSpan("span")(ZIO.attempt(logger.debug("test debug message"))) @@ ZIOAspect - .annotated("trace_id", "tId") - _ <- ZIO.attempt(logger.warn("hello {}", "world")) @@ ZIOAspect.annotated("user_id", "uId") - _ <- ZIO.attempt(logger.warn("{}..{}..{} ... go!", "3", "2", "1")) - _ <- ZIO.attempt(logger.warn("warn cause", testFailure)) - _ <- ZIO.attempt(logger.error("error", testFailure)) - _ <- ZIO.attempt(logger.error("error", null)) - } yield ()).exit + logger <- ZIO.attempt(org.slf4j.LoggerFactory.getLogger("test.logger")) + _ <- ZIO.logSpan("span")(ZIO.attempt(logger.debug("test debug message"))) @@ ZIOAspect + .annotated("trace_id", "tId") + _ <- ZIO.attempt(logger.warn("hello {}", "world")) @@ ZIOAspect.annotated("user_id", "uId") + _ <- ZIO.attempt(logger.warn("{}..{}..{} ... go!", "3", "2", "1")) + _ <- ZIO.attempt(logger.warn("warn cause", testFailure)) + _ <- ZIO.attempt(logger.error("error", testFailure)) + _ <- ZIO.attempt(logger.error("error", null)) + } yield ()).exit output <- ZTestLogger.logOutput lines = output.map { logEntry => - LogEntry( - logEntry.spans.map(_.label), - logEntry.logLevel, - logEntry.annotations, - logEntry.message(), - logEntry.cause - ) - } + LogEntry( + logEntry.spans.map(_.label), + logEntry.logLevel, + logEntry.annotations, + logEntry.message(), + logEntry.cause + ) + } } yield assertTrue( lines == Chunk( LogEntry( @@ -110,20 +110,20 @@ object Slf4jBridgeSpec extends ZIOSpecDefault { test("logs through slf4j without fiber ref propagation") { for { _ <- (for { - logger <- ZIO.attempt(org.slf4j.LoggerFactory.getLogger("test.logger")) - _ <- ZIO.attempt(logger.debug("test debug message")) @@ ZIOAspect.annotated("trace_id", "tId") - _ <- ZIO.attempt(logger.warn("hello {}", "world")) @@ ZIOAspect.annotated("user_id", "uId") - } yield ()).exit + logger <- ZIO.attempt(org.slf4j.LoggerFactory.getLogger("test.logger")) + _ <- ZIO.attempt(logger.debug("test debug message")) @@ ZIOAspect.annotated("trace_id", "tId") + _ <- ZIO.attempt(logger.warn("hello {}", "world")) @@ ZIOAspect.annotated("user_id", "uId") + } yield ()).exit output <- ZTestLogger.logOutput lines = output.map { logEntry => - LogEntry( - logEntry.spans.map(_.label), - logEntry.logLevel, - logEntry.annotations, - logEntry.message(), - logEntry.cause - ) - } + LogEntry( + logEntry.spans.map(_.label), + logEntry.logLevel, + logEntry.annotations, + logEntry.message(), + logEntry.cause + ) + } } yield assertTrue( lines == Chunk( LogEntry(