Skip to content

Commit

Permalink
Include ShortenFullyQualifiedTypeReferences with Slf4JToLog4j
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek committed Dec 18, 2024
1 parent 6a714a1 commit f49d9e1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/main/resources/META-INF/rewrite/log4j.yml
Original file line number Diff line number Diff line change
Expand Up @@ -308,3 +308,4 @@ recipeList:
newVersion: latest.release
- org.openrewrite.java.logging.ChangeLombokLogAnnotation:
loggingFramework: Log4j2
- org.openrewrite.java.ShortenFullyQualifiedTypeReferences
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ void loggerUsage() {
import org.slf4j.LoggerFactory;
import org.slf4j.Marker;
import org.slf4j.MarkerFactory;
class Test {
private static final Logger LOGGER = LoggerFactory.getLogger(Test.class);
private static final Marker MARKER = MarkerFactory.getMarker("MARKER");
public static void main(String[] args) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("logger message");
Expand All @@ -72,11 +72,11 @@ public static void main(String[] args) {
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.MarkerManager;
class Test {
private static final Logger LOGGER = LogManager.getLogger(Test.class);
private static final Marker MARKER = MarkerManager.getMarker("MARKER");
public static void main(String[] args) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("logger message");
Expand All @@ -96,7 +96,7 @@ void mdcConversion() {
java(
"""
import org.slf4j.MDC;
class Test {
void method() {
MDC.put("key", "value");
Expand All @@ -111,7 +111,7 @@ void method() {
"""
import org.apache.logging.log4j.CloseableThreadContext;
import org.apache.logging.log4j.ThreadContext;
class Test {
void method() {
ThreadContext.put("key", "value");
Expand All @@ -136,7 +136,7 @@ void logBuilder() {
import org.slf4j.Logger;
import org.slf4j.Marker;
import org.slf4j.event.Level;
class Test {
void method(Logger logger, Marker marker, Throwable t) {
logger.atLevel(Level.INFO)
Expand All @@ -150,7 +150,7 @@ void method(Logger logger, Marker marker, Throwable t) {
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.Marker;
class Test {
void method(Logger logger, Marker marker, Throwable t) {
logger.atLevel(Level.INFO)
Expand Down Expand Up @@ -222,7 +222,7 @@ void changeLombokLogAnnotation() {
java(
"""
import lombok.extern.slf4j.Slf4j;
@Slf4j
class Test {
void method() {
Expand All @@ -232,7 +232,7 @@ void method() {
""",
"""
import lombok.extern.log4j.Log4j2;
@Log4j2
class Test {
void method() {
Expand Down

0 comments on commit f49d9e1

Please sign in to comment.