pjfanning opened a new pull request, #653:
URL: https://github.com/apache/pekko-connectors-kafka/pull/653
### Motivation
Several log calls in main sources built their message with Scala string
interpolation, so the message was formatted even when the level was disabled. A
few others used an `s` prefix with no substitutions at all.
### Modification
- Converted the slf4j call sites in `testkit` to `{}` placeholders so
arguments are only rendered when the level is enabled:
- `KafkaTestKit.sleepMillis` / `sleepSeconds`
- `KafkaSpec.sleep`
- `KafkaTestKitChecks.periodicalCheck` — this is the one that mattered
most; it called `ex.getClass.getName` and `ex.getMessage` on every failed poll
of a retry loop regardless of level.
- Dropped the redundant `s` prefix on interpolation-free literals:
`s"Draining partitions {}"` in `TransactionalSources` (the `{}` is filled by
the logging adapter, the `s` did nothing) and `s"Polling"` in
`KafkaConsumerBenchmarks`.
- Replaced the manual `isDebugEnabled` guard in `KafkaConsumerActor` with a
placeholder call, since the logging adapter already checks the level before
formatting.
Left unchanged on purpose:
- `KafkaClusterSharding` already uses placeholders with `isInfoEnabled`
guards around its `mkString` work, and `KafkaContainerCluster` already uses
placeholders.
- The `benchmarks` module uses scala-logging's `LazyLogging`, whose macros
already wrap interpolation in a level check, so the remaining `s"…"` calls
there are lazy as-is.
- The `Partitions drained ${partitions.mkString(",")}` calls in
`TransactionalSources` use Pekko's `LoggingAdapter`, not slf4j; `mkString`
would be evaluated eagerly either way, and passing `partitions` through the
adapter would change the rendered output from `a,b` to `Set(a, b)`.
### Result
No message or argument is rendered unless the log level is enabled, and no
call site pays for interpolation it does not use. Log output text is unchanged.
### Tests
- `sbt "core/compile" "testkit/compile" "benchmarks/compile"` - success
(Scala 2.13.18)
- `sbt "++3.3.8 core/compile" "++3.3.8 testkit/compile"` - success (Scala
3.3.8)
- `sbt "core/scalafmtCheck" "testkit/scalafmtCheck"
"benchmarks/scalafmtCheck"` - success
- `sbt "core/mimaReportBinaryIssues" "testkit/mimaReportBinaryIssues"` -
success
- No directional test added: this changes only the shape of logging calls,
with no behavior or API change.
### References
None - logging cleanup found while reviewing main sources
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]