refactor(common): use SLF4J parameterized logging instead of string concatenation#19158
Conversation
…oncatenation
Convert log string concatenation to {} placeholders across hudi-common.
Mechanical and behavior-preserving. Notable manual handling:
- ZookeeperTestService: pass e.toString() (not e) so the exception stays an
inline message value instead of being peeled as the SLF4J stacktrace arg,
preserving the existing 'ignore as expected' behavior.
- ConfigUtils: drop redundant path.toString() in the parameterized arg.
- JmxMetricsReporter: the message wraps the value in literal braces; written
as "{port: {}}" so SLF4J fills the inner {} and keeps the outer braces.
hudi-agent
left a comment
There was a problem hiding this comment.
Thanks for the contribution! This PR mechanically converts string-concatenation log/LOG calls to SLF4J {} parameterized logging across hudi-common (main + tests). I traced each changed statement: placeholder counts match argument counts throughout, no arguments are arrays (which SLF4J would format differently from concatenation), and the two throwable-adjacent edge cases are handled correctly — ConfigUtils passes path + e so the stack trace still logs in both SLF4J 1.7.x and 2.0.x, and ZookeeperTestService's e.toString() correctly avoids the bare-Throwable-as-last-arg divergence. No correctness issues found. A few style/readability suggestions in the inline comments. Please take a look, and this should be ready for a Hudi committer or PMC member to take it from here. One small redundancy in the ZookeeperTestService change; everything else is clean.
cc @yihua
Describe the issue this Pull Request addresses
A number of
log/LOGcalls inhudi-commonbuild their message with+string concatenation. This eagerly builds the string even when the level is disabled and reads worse than a parameterized statement. This PR converts them to SLF4J{}templating. Part of the ongoing logging cleanup (follows #19155, #19156, #19157).Summary and Changelog
log/LOGcalls to{}placeholders acrosshudi-common(main + tests). Mechanical and behavior-preserving.ZookeeperTestService: the caughtIOExceptionis passed ase.toString(), not a baree. Passed as a trailinge, SLF4J would peel it as the stacktrace throwable, leave the placeholder literal, and dump a stack on an intentionally-ignored path (// ignore as this is expected).toString()keeps it an inline message value, preserving the original output.ConfigUtils: dropped a redundantpath.toString(); the trailingestays the throwable arg, so the stacktrace is logged as before.JmxMetricsReporter: one message wraps the value in literal braces; written as{port: {}}so SLF4J fills the inner{}and prints the outer braces literally.RocksDbBasedFileSystemView: one long line wrapped across two lines to stay within the 200-char limit.Impact
none - purely mechanical, behavior-preserving logging change.
Risk Level
none
Documentation Update
none
Note: a couple of files still use plain
LoggerFactory.getLoggerLOGfields. Migrating those to the Lombok@Slf4jannotation will be done in a separate round of cleanup sweeps; this PR only covers the concatenation-to-templating conversion.Contributor's checklist