Skip to content

Commit

Permalink
short circuit the logl level cheks when logger is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
gciuloaica committed May 19, 2022
1 parent 20bef93 commit 42f6d3c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions zio-http-logging/src/main/scala/zhttp/logging/Logger.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

1 comment on commit 42f6d3c

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 Performance Benchmark:

Concurrency: 256
Requests/sec: 932752.43

Please sign in to comment.