Skip to content

refactor(cli): use SLF4J parameterized logging instead of string concatenation#19159

Merged
voonhous merged 2 commits into
apache:masterfrom
voonhous:cleanup-slf4j-log-templating-cli
Jul 4, 2026
Merged

refactor(cli): use SLF4J parameterized logging instead of string concatenation#19159
voonhous merged 2 commits into
apache:masterfrom
voonhous:cleanup-slf4j-log-templating-cli

Conversation

@voonhous

@voonhous voonhous commented Jul 3, 2026

Copy link
Copy Markdown
Member

Describe the issue this Pull Request addresses

A number of log calls in hudi-cli build 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, #19158).

Summary and Changelog

  • Converted string-concatenation log calls to {} placeholders across hudi-cli command classes. Mechanical and behavior-preserving.
  • Manual handling worth calling out:
    • MetadataCommand: two long multi-line concatenations (FS / metadata file-size mismatch) rewritten as wrapped parameterized calls; the inline == equality becomes a boolean {} arg.
    • RepairsCommand: dropped a redundant hoodieInstant.toString() in the parameterized arg.
    • TableCommand: kept schema.toString(true) as-is - it is a formatted print, not a redundant no-arg toString().
    • LockAuditingCommand: the trailing e stays the throwable arg, so the stacktrace is logged as before.

Impact

none - purely mechanical, behavior-preserving logging change.

Risk Level

none

Documentation Update

none

Contributor's checklist

  • Read through contributor's guide
  • Enough context is provided in the sections above
  • Adequate tests were added if applicable

…atenation

Convert log string concatenation to {} placeholders across hudi-cli.
Mechanical and behavior-preserving. Notable handling:
- MetadataCommand: two long multi-line concatenations (FS/metadata file size
  mismatch) rewritten as wrapped parameterized calls; the inline equality
  expression becomes a boolean {} arg.
- RepairsCommand: drop redundant hoodieInstant.toString() in the parameterized arg.
- TableCommand: kept schema.toString(true) as-is (formatted print, not a
  redundant no-arg toString).
@voonhous voonhous changed the title refactor(cli): use SLF4J parameterized logging instead of string conc… refactor(cli): use SLF4J parameterized logging instead of string concatenation Jul 3, 2026
@github-actions github-actions Bot added the size:S PR with lines of changes in (10, 100] label Jul 3, 2026

@hudi-agent hudi-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ 🤖 This review was generated by an AI agent and may contain mistakes. Please verify any suggestions before applying.

Thanks for working on this! This PR mechanically converts string-concatenation log calls to SLF4J parameterized ({}) logging across several hudi-cli command classes. I verified placeholder/argument counts and the trailing-Throwable handling in each converted call, and they all look correct and behavior-preserving. 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. Mostly a clean mechanical refactor; one spot in TableCommand where the parameterized logging conversion doesn't fully achieve its intent.

cc @yihua

Comment thread hudi-cli/src/main/java/org/apache/hudi/cli/commands/TableCommand.java Outdated
Extract schema.toString(true) to a local in the outputFilePath branch so it
is computed once and reused for both the log statement and writeToFile,
instead of serializing the schema twice. Per review.
@voonhous voonhous enabled auto-merge (squash) July 4, 2026 09:49

@hudi-agent hudi-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ 🤖 This review was generated by an AI agent and may contain mistakes. Please verify any suggestions before applying.

Thanks for working on this! This PR mechanically converts string-concatenation log calls to SLF4J {} parameterized logging across hudi-cli. The placeholder/argument counts and trailing throwable args all check out. While tracing the rewritten MetadataCommand size-mismatch statement, I noticed one likely pre-existing bug in the logged "FS size" value that's worth double-checking in the inline comment. Please take a look at any inline comments, and this should be ready for a Hudi committer or PMC member to take it from here.

entry.getKey(),
entry.getValue().getLength() == pathInfoMap.get(entry.getKey()).getLength(),
entry.getValue().getLength(),
metadataPathInfoMap.get(entry.getKey()).getLength());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🤖 Since you're rewriting this statement anyway — in this loop entry comes from metadataPathInfoMap, so metadataPathInfoMap.get(entry.getKey()).getLength() is just entry.getValue().getLength() again (the metadata size). The FS size {} arg looks like it should be pathInfoMap.get(entry.getKey()).getLength() instead, matching the equality check on the line above. Could you confirm?

⚠️ AI-generated; verify before applying. React 👍/👎 to flag quality.

@hudi-bot

hudi-bot commented Jul 4, 2026

Copy link
Copy Markdown
Collaborator

CI report:

Bot commands @hudi-bot supports the following commands:
  • @hudi-bot run azure re-run the last Azure build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S PR with lines of changes in (10, 100]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants