Skip to content

Refactor: guard all logger calls with isXxxEnabled() checks#101

Open
Copilot wants to merge 1 commit intomainfrom
copilot/refactor-logging-to-check-trace-enabled
Open

Refactor: guard all logger calls with isXxxEnabled() checks#101
Copilot wants to merge 1 commit intomainfrom
copilot/refactor-logging-to-check-trace-enabled

Conversation

Copy link
Contributor

Copilot AI commented Mar 25, 2026

Unguarded logger calls evaluate their arguments eagerly regardless of log level, causing unnecessary string construction, method calls, and lambda execution at runtime.

Changes

  • Wrapped all logger.trace(...), logger.info(...), and logger.warn(...) calls across 7 files in the appropriate isXxxEnabled() guard
  • Grouped consecutive trace calls (e.g. forEach lambda in ServiceInstanceUtils) under a single guard block to avoid redundant level checks

Before:

logger.trace("The ServerProperties property is changed to: {}", getProperties(environment, serverPropertyNames));

After:

if (logger.isTraceEnabled()) {
    logger.trace("The ServerProperties property is changed to: {}", getProperties(environment, serverPropertyNames));
}

Files affected

File Level Calls
DecoratedFeignComponent trace 2
FeignClientSpecificationPostProcessor trace 1
TomcatDynamicConfigurationListener trace 3
ServiceInstanceUtils trace 3 (incl. forEach lambda)
ServiceRegistrationEndpoint info, warn 2
ServiceDeregistrationEndpoint info, warn 2
WebServiceRegistryAutoConfiguration trace 1

@sonarqubecloud
Copy link

@mercyblitz mercyblitz marked this pull request as ready for review March 25, 2026 05:28
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.

2 participants