Skip to content
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

Add basic JUL to Log4j API conversion #133

Merged
merged 7 commits into from
Dec 12, 2023

Conversation

ppkarwasz
Copy link
Contributor

What's changed?

This PR converts the most commonly used JUL methods to their Log4j API equivalents:

  • Logger#getLogger,
  • all Logger#<logging_level methods,
  • Logger#entering,
  • Logger#exiting.

What's your motivation?

This is part of our apache/logging-log4j2#2080 task.
The main motivation is a user request for support (cf. apache/logging-log4j2#2083), hence the implementation of the entering/exiting rules.

Closes #132

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices
  • I've used the IntelliJ IDEA auto-formatter on affected files

ppkarwasz and others added 2 commits December 12, 2023 18:27
This PR converts the most commonly used JUL methods to their
Log4j API equivalents:

 * `Logger#getLogger`,
 * all `Logger#<logging_level` methods,
 * `Logger#entering`,
 * `Logger#exiting`.
- Strip final from local variables
- Pass `UsesMethod` directly into Preconditions
- Create a MethodMatcher field used twice
- Inline `EnteringMethodVisitor`
- Match on `entering(String, String, ..)`
- Drop `@JsonPOJOBuilder`
Copy link
Contributor

@timtebeek timtebeek left a comment

Choose a reason for hiding this comment

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

Thanks a lot yet again! I've made some polishing commits to align with our other recipe implementations, most notably cc791e5 with more details in the commit. Other than that just great seeing how quickly you're productive building recipes here.

@timtebeek timtebeek added the recipe Recipe Requested label Dec 12, 2023
@timtebeek timtebeek merged commit 88b96ad into openrewrite:main Dec 12, 2023
1 check passed
@ppkarwasz ppkarwasz deleted the jul-to-log4j branch December 12, 2023 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
recipe Recipe Requested
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Add a JUL to Log4j API conversion
2 participants