Skip to content

Conversation

@he1l0world
Copy link
Contributor

@he1l0world he1l0world commented Jul 14, 2025

Description

This PR improves logging consistency across the logging statements in ApiServer.java

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • [] Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • build/CI
  • test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

How did you try to break this feature and the system with this change?

@sureshanaparti sureshanaparti requested a review from Copilot July 14, 2025 08:36
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR standardizes logger message formatting in ApiServer.java by converting from string concatenation to parameterized logging. The changes improve logging performance and consistency by using placeholders ({}) instead of string concatenation with the + operator.

  • Replaces string concatenation with parameterized logging format across multiple log statements
  • Maintains the same log message content while improving performance and readability
  • Updates debug, trace, info, and warn level logging statements

Copy link
Contributor

@sureshanaparti sureshanaparti left a comment

Choose a reason for hiding this comment

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

clgtm

@sureshanaparti
Copy link
Contributor

@blueorangutan package

@blueorangutan
Copy link

@sureshanaparti a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@codecov
Copy link

codecov bot commented Jul 14, 2025

Codecov Report

❌ Patch coverage is 0% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 17.57%. Comparing base (db61470) to head (f976759).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
server/src/main/java/com/cloud/api/ApiServer.java 0.00% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               main   #11188   +/-   ##
=========================================
  Coverage     17.56%   17.57%           
- Complexity    15548    15550    +2     
=========================================
  Files          5913     5913           
  Lines        529440   529440           
  Branches      64670    64670           
=========================================
+ Hits          93019    93025    +6     
+ Misses       425963   425957    -6     
  Partials      10458    10458           
Flag Coverage Δ
uitests 3.58% <ø> (ø)
unittests 18.63% <0.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@blueorangutan
Copy link

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 14161

Copy link
Contributor

@DaanHoogland DaanHoogland left a comment

Choose a reason for hiding this comment

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

clgtm, it is a trivial change, so can we consider if the message level needs adjusting in the same PR? cc @sureshanaparti @JoaoJandre @bernardodemarco @winterhazel

final String keyStr = (String)key;
final String[] value = (String[])params.get(key);
logger.trace(" key: " + keyStr + ", value: " + ((value == null) ? "'null'" : value[0]));
logger.trace(" key: {}, value: {}", keyStr, (value == null) ? "'null'" : value[0]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
logger.trace(" key: {}, value: {}", keyStr, (value == null) ? "'null'" : value[0]);
logger.trace(" key: {}, value: {}", keyStr, () -> (value == null) ? "'null'" : value[0]);

Since this is on trace (rarely used) It would be better to pass a lambda function that will me evaluated only if trace is on.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestion! Just to confirm, I saw we are using Log4j 2.19.0, it doesn't support lambda directly, but it does support Supplier, which should work the same.

@he1l0world
Copy link
Contributor Author

@JoaoJandre Sounds good! I will address them!

@github-actions
Copy link

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

@JoaoJandre
Copy link
Contributor

Hi @he1l0world, could you resolve the conflicts here?

@he1l0world
Copy link
Contributor Author

@JoaoJandre Updated

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.

5 participants