-
Notifications
You must be signed in to change notification settings - Fork 2
Refactor: Use Standard OpenRewrite Recipes to implement Slf4j logging automatically #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
… recipe to use slf4j logging
… to use @Sl4j annotation for loggers
Replaced `System.out.println` with proper logging using `log.error` to ensure exceptions are logged consistently and include stack trace details. This improves debugging and aligns with standard logging practices.
Eliminated unnecessary `verify(mockUtility)` calls from unit tests to improve clarity and maintain focus on actual test assertions. This helps streamline the code and reduce noise in test output.
Eliminated unnecessary `verify(mockUtility)` calls from unit tests to improve clarity and maintain focus on actual test assertions. This helps streamline the code and reduce noise in test output.
Eliminated unnecessary `verify(mockUtility)` calls from unit tests to improve clarity and maintain focus on actual test assertions. This helps streamline the code and reduce noise in test output.
Eliminated unnecessary `verify(mockUtility)` calls from unit tests to improve clarity and maintain focus on actual test assertions. This helps streamline the code and reduce noise in test output.
Log message assertions were removed as they provide limited value and rely on inspecting logs, which is discouraged. A low-value test was disabled due to its dependency on log messages without meaningful functional validation.
Removed unnecessary log and verify statements from CertExpirationConsumerTest to improve code clarity and maintainability. These changes help streamline test assertions without impacting functionality.
Added SLF4J best practices recipe to enforce proper logging conventions. Updated Maven dependencies and configuration to include the new rewrite-logging-frameworks artifact.
…actices to implement best practices Replaced `log.info` with appropriate `log.warn` or `log.error` in error-prone scenarios and updated parameterized logging to use placeholders instead of string formatting. This improves log readability, corrects log levels, and standardizes logging practices across the codebase.
verify(mockUtility, times(3)).logWithDate(logMessageCaptor.capture(), eq(ValidateTmdd.class)); | ||
Assertions.assertEquals("Error sending summary email:", logMessageCaptor.getAllValues().get(1)); | ||
Assertions.assertEquals("Failed to send error summary email:", logMessageCaptor.getAllValues().get(2)); | ||
// TODO: how to assert behavior without inspecting logs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: this TODO is intentional. The value of this automated refactor is to get more useful and detailed logs for debugging and system validation. The test in question is highly coupled to logging to the point that verification of behaviors is difficult without inspecting the logs directly. The value of the refactor was determined to greatly outweigh the value of this edge case test verification. Instead of removing the test entirely, I disabled it with a note for future maintainers about why it's disabled. Should we find in the future that this test case is important, the structure is there and available to whomever decides to reimplement the test.
Deleted Maven wrapper files to clean up the project. These files are no longer required as the project setup does not rely on the Maven wrapper tooling.
Description
Use OpenRewrite to replace direct system calls with structured logging. This will significantly improve maintainers' ability to understand and debug program execution. The only manual edits were made in the tests. All other code changes were automatically performed by their respective OpenRewrite Recipes using the Maven plugin.
How
logWithDate
and inlined theirSystem.out.println
calls (necessary prep for the next step)@Slf4j
annotations instead of explicit properties