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

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

Merged
merged 3 commits into from
Jan 26, 2024

Conversation

hygt
Copy link
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
@@ -7,7 +7,7 @@ object Versions {
val circe = "0.14.6"
val circeGenericExtras = "0.14.3"
val circeYaml = "0.15.1"
val helidon = "4.0.0"
val helidon = "4.0.3"
Copy link
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?


val renderer: ProtoRenderer = new ProtoRenderer()
val interpreter = new ProtobufInterpreter(new EndpointToProtobufMessage(), new EndpointToProtobufService())
val proto = interpreter.toProtobuf(endpoints, Some(packageName))

val renderedProto = renderer.render(proto)

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
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
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
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
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
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?

noLog = ()
)

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
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?

@@ -82,10 +85,11 @@ object AwsLambdaRuntimeInvocation extends StrictLogging {
val sendResult: (RequestEvent, Either[Throwable, AwsResponse]) => F[Unit] = (event, result) =>
result match {
case Right(response) =>
logger.info(s"Request event ${event.requestId} completed successfully")
logger.info("Request event {} completed successfully", event.requestId)
Copy link
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
23 checks passed
@kciesielski
Copy link
Member

Thanks a lot @hygt!

@adamw
Copy link
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