Skip to content

Remove dependency on logback-classic and scala-logging where unnecessary#3471

Merged
kciesielski merged 3 commits into
softwaremill:masterfrom
hygt:fix/remove-scala-logging
Jan 26, 2024
Merged

Remove dependency on logback-classic and scala-logging where unnecessary#3471
kciesielski merged 3 commits into
softwaremill:masterfrom
hygt:fix/remove-scala-logging

Conversation

@hygt
Copy link
Copy Markdown
Contributor

@hygt hygt commented Jan 22, 2024

Fixes #3464

@hygt hygt marked this pull request as draft January 22, 2024 23:03
@hygt hygt force-pushed the fix/remove-scala-logging branch from a1a4895 to a5cc585 Compare January 23, 2024 10:11
@hygt hygt force-pushed the fix/remove-scala-logging branch from a5cc585 to 4b4f1c9 Compare January 23, 2024 10:32
@hygt hygt marked this pull request as ready for review January 23, 2024 13:54
Comment thread project/Versions.scala Outdated
val circeGenericExtras = "0.14.3"
val circeYaml = "0.15.1"
val helidon = "4.0.0"
val helidon = "4.0.3"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nitpick: Could we keep this change for another PR?


logger.debug(s"Generated protobuf structure: [$renderedProto]")
logger.info(s"Writing proto file to the path [$path]")
logger.debug("Generated protobuf structure: [{}]", renderedProto)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

suggestion: To take advantage of slf4sj's deferred evaluation when formatting, this should be

logger.debug("Generated protobuf structure: [{}]", renderer.render(proto))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we're using slf4j, not slf4s, so if at all, this would have to be a lambda to be lazily evaluated?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Oh right, this has to be a lambda. slf4j has API for that, I think only in the 2.0's fluent API https://www.slf4j.org/manual.html#fluent

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In any case renderedProto is called again on line 28, so I don't think it matters?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, I didn't notice that. Maybe we can keep the standard string interpolation then?

private def debugLog(msg: String, exOpt: Option[Throwable]): Unit = exOpt match {
case Some(e) => log.log(Level.FINE, msg, e)
case None => log.log(Level.FINE, msg)
case Some(e) => log.debug(msg, e)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

suggestion: Shouldn't this method check logger.isDebugEnabled() as well?

result match {
case Right(response) =>
logger.info(s"Request event ${event.requestId} completed successfully")
logger.info("Request event {} completed successfully", event.requestId)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nitpick: While the slf4j's formatter's deferred evaluation can help to avoid evaluating expensive expressions, I don't think it should be used in all cases. Here we have a simple expression (event.requestId) and INFO level, so it will always be evaluated anyway. Using interpolated string where possible makes the message much more readable in the code IMO. (This comment applies to other usages where I don't see a clear gain, like logger.error calls above and below).

@kciesielski kciesielski merged commit ce082aa into softwaremill:master Jan 26, 2024
@kciesielski
Copy link
Copy Markdown
Member

Thanks a lot @hygt!

@adamw
Copy link
Copy Markdown
Member

adamw commented Jan 26, 2024

Thanks! :)

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.

[BUG] Hard dependency on scala-logging and logback

3 participants