From 42f6d3cebd5ff2c27f665274bee2ac523f67a446 Mon Sep 17 00:00:00 2001 From: Gabriel Ciuloaica Date: Thu, 19 May 2022 12:13:40 +0300 Subject: [PATCH] short circuit the logl level cheks when logger is disabled --- .../src/main/scala/zhttp/logging/Logger.scala | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/zio-http-logging/src/main/scala/zhttp/logging/Logger.scala b/zio-http-logging/src/main/scala/zhttp/logging/Logger.scala index 9ec867a48d..3e64445e72 100644 --- a/zio-http-logging/src/main/scala/zhttp/logging/Logger.scala +++ b/zio-http-logging/src/main/scala/zhttp/logging/Logger.scala @@ -52,11 +52,11 @@ final case class Logger(transports: List[LoggerTransport]) extends LoggerMacroEx ): Unit = transports.foreach(_.log(msg, cause, level, sourceLocation)) val isEnabled: Boolean = transports.exists(_.level != LogLevel.Disable) - val isDebugEnabled: Boolean = transports.exists(_.isDebugEnabled) - val isErrorEnabled: Boolean = transports.exists(_.isErrorEnabled) - val isInfoEnabled: Boolean = transports.exists(_.isInfoEnabled) - val isTraceEnabled: Boolean = transports.exists(_.isTraceEnabled) - val isWarnEnabled: Boolean = transports.exists(_.isWarnEnabled) + val isDebugEnabled: Boolean = isEnabled && transports.exists(_.isDebugEnabled) + val isErrorEnabled: Boolean = isEnabled && transports.exists(_.isErrorEnabled) + val isInfoEnabled: Boolean = isEnabled && transports.exists(_.isInfoEnabled) + val isTraceEnabled: Boolean = isEnabled && transports.exists(_.isTraceEnabled) + val isWarnEnabled: Boolean = isEnabled && transports.exists(_.isWarnEnabled) /** * Creates a new logger that will log messages that start with the given