Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure log message laziness in Slf4jLogger with logging guards #233

Merged
merged 1 commit into from
Mar 1, 2021
Merged

Ensure log message laziness in Slf4jLogger with logging guards #233

merged 1 commit into from
Mar 1, 2021

Conversation

aartigao
Copy link
Contributor

Added logging guards to prevent log message evaluation if current logger is disabled.

Currently if you have a potentially expensive interpolated String like:

log.debug(s"Pushing: $datums")

where $datums's toString is an expensive operation it gets evaluated even if the log level is disabled. This evaluation takes place at the boundary between Scala (ZIO Logging) and Java (SLF4J Logging).

This PR prevents that by setting logging guards before SLF4J Logging invocation, making the operations in ZIO side truly lazy.

Added logging guards to prevent log message evaluation if current logger is disabled.
@pshemass pshemass merged commit 796acca into zio:master Mar 1, 2021
@pshemass
Copy link
Collaborator

pshemass commented Mar 1, 2021

@aartigao thanks for that fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants