From aa428a784222a64b9d81dfa5fd7efcdbbf6a33de Mon Sep 17 00:00:00 2001 From: Omer Atzmon Date: Sat, 6 Sep 2025 18:23:53 +0300 Subject: [PATCH 1/4] Support for unplanned logger calls --- .../weaver/log4j2/LoggerConversionHandler.java | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/log4j-weaver/src/main/java/org/apache/logging/log4j/weaver/log4j2/LoggerConversionHandler.java b/log4j-weaver/src/main/java/org/apache/logging/log4j/weaver/log4j2/LoggerConversionHandler.java index 05878744..e419fcc3 100644 --- a/log4j-weaver/src/main/java/org/apache/logging/log4j/weaver/log4j2/LoggerConversionHandler.java +++ b/log4j-weaver/src/main/java/org/apache/logging/log4j/weaver/log4j2/LoggerConversionHandler.java @@ -132,17 +132,6 @@ public void handleMethodInstruction(LocationMethodVisitor mv, String name, Strin case "throwing": handleCatchingThrowing(mv, descriptor, "throwing".equals(name)); break; - case "isDebugEnabled": - case "isEnabled": - case "isErrorEnabled": - case "isFatalEnabled": - case "isInfoEnabled": - case "isTraceEnabled": - case "isWarnEnabled": - case "logMessage": - // These are NOPs - mv.invokeInterface(LOGGER_TYPE, new Method(name, descriptor)); - break; case "traceEntry": handleTraceEntry(mv, descriptor); break; @@ -150,7 +139,8 @@ public void handleMethodInstruction(LocationMethodVisitor mv, String name, Strin handleTraceExit(mv, descriptor); break; default: - throw new ConversionException("Unsupported method 'org.apache.logging.log4j.Logger#" + name + "'."); + // The default is to not change the original call + mv.invokeInterface(LOGGER_TYPE, new Method(name, descriptor)); } } From 84a1e327703e29518d967b4f4ed09e9aa6b3d2e8 Mon Sep 17 00:00:00 2001 From: Omer Atzmon Date: Sat, 6 Sep 2025 18:20:48 +0300 Subject: [PATCH 2/4] added tests for unplanned logging and removed manual line counting --- .../LoggerConversionHandlerExample.java | 37 +++++++++++-------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/log4j-weaver/src/test/java/org/apache/logging/log4j/weaver/log4j2/LoggerConversionHandlerExample.java b/log4j-weaver/src/test/java/org/apache/logging/log4j/weaver/log4j2/LoggerConversionHandlerExample.java index e56048bd..aead6676 100644 --- a/log4j-weaver/src/test/java/org/apache/logging/log4j/weaver/log4j2/LoggerConversionHandlerExample.java +++ b/log4j-weaver/src/test/java/org/apache/logging/log4j/weaver/log4j2/LoggerConversionHandlerExample.java @@ -18,6 +18,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import java.util.List; import org.apache.logging.log4j.Level; @@ -62,12 +63,10 @@ public class LoggerConversionHandlerExample { private static final Logger logger = LogManager.getLogger(); - private static final int referenceLine = 65; - public void testFatal(final ListAppender app) { app.clear(); final String methodName = "testFatal"; - int lineNumber = referenceLine + 5; // current line number + int lineNumber = getLineNumber(); // current line number logger.fatal(CHAR_SEQUENCE); assertLocationEquals(methodName, ++lineNumber, app); logger.fatal(CHAR_SEQUENCE, THROWABLE); @@ -165,7 +164,7 @@ public void testFatal(final ListAppender app) { public void testError(final ListAppender app) { app.clear(); final String methodName = "testError"; - int lineNumber = referenceLine + 103; // current line number + int lineNumber = getLineNumber(); // current line number logger.error(CHAR_SEQUENCE); assertLocationEquals(methodName, ++lineNumber, app); logger.error(CHAR_SEQUENCE, THROWABLE); @@ -263,7 +262,7 @@ public void testError(final ListAppender app) { public void testWarn(final ListAppender app) { app.clear(); final String methodName = "testWarn"; - int lineNumber = referenceLine + 201; // current line number + int lineNumber = getLineNumber(); // current line number logger.warn(CHAR_SEQUENCE); assertLocationEquals(methodName, ++lineNumber, app); logger.warn(CHAR_SEQUENCE, THROWABLE); @@ -361,7 +360,7 @@ public void testWarn(final ListAppender app) { public void testInfo(final ListAppender app) { app.clear(); final String methodName = "testInfo"; - int lineNumber = referenceLine + 299; // current line number + int lineNumber = getLineNumber(); // current line number logger.info(CHAR_SEQUENCE); assertLocationEquals(methodName, ++lineNumber, app); logger.info(CHAR_SEQUENCE, THROWABLE); @@ -459,7 +458,7 @@ public void testInfo(final ListAppender app) { public void testDebug(final ListAppender app) { app.clear(); final String methodName = "testDebug"; - int lineNumber = referenceLine + 397; // current line number + int lineNumber = getLineNumber(); // current line number logger.debug(CHAR_SEQUENCE); assertLocationEquals(methodName, ++lineNumber, app); logger.debug(CHAR_SEQUENCE, THROWABLE); @@ -557,7 +556,7 @@ public void testDebug(final ListAppender app) { public void testTrace(final ListAppender app) { app.clear(); final String methodName = "testTrace"; - int lineNumber = referenceLine + 495; // current line number + int lineNumber = getLineNumber(); // current line number logger.trace(CHAR_SEQUENCE); assertLocationEquals(methodName, ++lineNumber, app); logger.trace(CHAR_SEQUENCE, THROWABLE); @@ -655,7 +654,7 @@ public void testTrace(final ListAppender app) { public void testLog(final ListAppender app) { app.clear(); final String methodName = "testLog"; - int lineNumber = referenceLine + 593; // current line number + int lineNumber = getLineNumber(); // current line number logger.log(Level.INFO, CHAR_SEQUENCE); assertLocationEquals(methodName, ++lineNumber, app); logger.log(Level.INFO, CHAR_SEQUENCE, THROWABLE); @@ -753,7 +752,7 @@ public void testLog(final ListAppender app) { public void testFrames(final ListAppender app) { app.clear(); final String methodName = "testFrames"; - final int lineNumber = referenceLine + 691; // Current line + final int lineNumber = getLineNumber(); // Current line int i = 0; while (i < 2) { if (i < 1) { @@ -782,7 +781,7 @@ public void testFrames(final ListAppender app) { public void testPrintf(final ListAppender app) { app.clear(); final String methodName = "testPrintf"; - int lineNumber = referenceLine + 720; // Current line + int lineNumber = getLineNumber(); // Current line logger.printf(Level.INFO, "Hello %s.%s", "LoggerConversionHandlerExample", methodName); assertLocationEquals(methodName, ++lineNumber, app); logger.printf(Level.INFO, MARKER, "Hello %s.%s", "LoggerConversionHandlerExample", methodName); @@ -792,7 +791,7 @@ public void testPrintf(final ListAppender app) { public void testLogBuilder(final ListAppender app) { app.clear(); final String methodName = "testLogBuilder"; - int lineNumber = referenceLine + 730; // Current line + int lineNumber = getLineNumber(); // Current line logger.always().log(); assertLocationEquals(methodName, ++lineNumber, app); logger.atDebug().log(); @@ -829,6 +828,10 @@ public void testPassthrough(final ListAppender app) { assertTrue(logger.isTraceEnabled(MARKER)); assertTrue(logger.isWarnEnabled()); assertTrue(logger.isWarnEnabled(MARKER)); + assertDoesNotThrow(logger::getName); + assertDoesNotThrow(logger::getLevel); + assertDoesNotThrow(logger::getFlowMessageFactory); + assertDoesNotThrow(logger::getClass); app.clear(); logger.logMessage(Level.INFO, MARKER, LoggerConversionHandlerExample.class.getName(), null, MESSAGE, THROWABLE); assertThat(app.getEvents()).hasSize(1); @@ -837,7 +840,7 @@ public void testPassthrough(final ListAppender app) { public void testCatchingThrowing(final ListAppender app) { app.clear(); final String methodName = "testCatchingThrowing"; - int lineNumber = referenceLine + 775; // Current line + int lineNumber = getLineNumber(); // Current line logger.catching(THROWABLE); assertThat(app.getEvents()).allMatch(event -> AbstractLogger.CATCHING_MARKER.equals(event.getMarker())); assertLocationEquals(methodName, ++lineNumber, app); @@ -855,7 +858,7 @@ public void testCatchingThrowing(final ListAppender app) { public void testTraceEntry(final ListAppender app) { app.clear(); final String methodName = "testTraceEntry"; - int lineNumber = referenceLine + 793; // Current line + int lineNumber = getLineNumber(); // Current line EntryMessage entryMessage = logger.traceEntry(); LogEvent event = assertLocationEquals(methodName, ++lineNumber, app); assertThat(event.getMarker()).isEqualTo(AbstractLogger.ENTRY_MARKER); @@ -885,7 +888,7 @@ public void testTraceEntry(final ListAppender app) { public void testTraceExit(final ListAppender app) { app.clear(); final String methodName = "testTraceExit"; - int lineNumber = referenceLine + 823; // Current line + int lineNumber = getLineNumber(); // Current line logger.traceExit(); LogEvent event = assertLocationEquals(methodName, ++lineNumber, app); assertThat(event.getMarker()).isEqualTo(AbstractLogger.EXIT_MARKER); @@ -942,4 +945,8 @@ private static LogEvent assertLocationEquals( app.clear(); return event; } + + private static int getLineNumber() { + return Thread.currentThread().getStackTrace()[2].getLineNumber(); + } } From e924f9bcb64a79a0b07ce857f849f6c6f33f44ac Mon Sep 17 00:00:00 2001 From: Omer Atzmon Date: Sat, 6 Sep 2025 18:21:02 +0300 Subject: [PATCH 3/4] remove manual lines completely --- .../LoggerConversionHandlerExample.java | 749 +++++++++--------- 1 file changed, 380 insertions(+), 369 deletions(-) diff --git a/log4j-weaver/src/test/java/org/apache/logging/log4j/weaver/log4j2/LoggerConversionHandlerExample.java b/log4j-weaver/src/test/java/org/apache/logging/log4j/weaver/log4j2/LoggerConversionHandlerExample.java index aead6676..90da230e 100644 --- a/log4j-weaver/src/test/java/org/apache/logging/log4j/weaver/log4j2/LoggerConversionHandlerExample.java +++ b/log4j-weaver/src/test/java/org/apache/logging/log4j/weaver/log4j2/LoggerConversionHandlerExample.java @@ -66,748 +66,738 @@ public class LoggerConversionHandlerExample { public void testFatal(final ListAppender app) { app.clear(); final String methodName = "testFatal"; - int lineNumber = getLineNumber(); // current line number logger.fatal(CHAR_SEQUENCE); - assertLocationEquals(methodName, ++lineNumber, app); + assertLocationEquals(methodName, app); logger.fatal(CHAR_SEQUENCE, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.fatal(MARKER, CHAR_SEQUENCE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.fatal(MARKER, CHAR_SEQUENCE, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.fatal(MESSAGE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.fatal(MESSAGE, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.fatal(MARKER, MESSAGE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.fatal(MARKER, MESSAGE, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.fatal(OBJECT); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.fatal(OBJECT, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.fatal(MARKER, OBJECT); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.fatal(MARKER, OBJECT, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.fatal(STRING); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.fatal(MARKER, STRING); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.fatal(STRING, P0); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.fatal(MARKER, STRING, P0); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.fatal(STRING, P0, P1); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.fatal(MARKER, STRING, P0, P1); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.fatal(STRING, P0, P1, P2); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.fatal(MARKER, STRING, P0, P1, P2); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.fatal(STRING, P0, P1, P2, P3); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.fatal(MARKER, STRING, P0, P1, P2, P3); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.fatal(STRING, P0, P1, P2, P3, P4); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.fatal(MARKER, STRING, P0, P1, P2, P3, P4); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.fatal(STRING, P0, P1, P2, P3, P4, P5); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.fatal(MARKER, STRING, P0, P1, P2, P3, P4, P5); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.fatal(STRING, P0, P1, P2, P3, P4, P5, P6); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.fatal(MARKER, STRING, P0, P1, P2, P3, P4, P5, P6); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.fatal(STRING, P0, P1, P2, P3, P4, P5, P6, P7); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.fatal(MARKER, STRING, P0, P1, P2, P3, P4, P5, P6, P7); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.fatal(STRING, P0, P1, P2, P3, P4, P5, P6, P7, P8); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.fatal(MARKER, STRING, P0, P1, P2, P3, P4, P5, P6, P7, P8); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.fatal(STRING, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.fatal(MARKER, STRING, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.fatal(STRING, PARRAY); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.fatal(MARKER, STRING, PARRAY); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.fatal(() -> MESSAGE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.fatal(() -> MESSAGE, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.fatal(MARKER, () -> MESSAGE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.fatal(MARKER, () -> MESSAGE, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.fatal(() -> OBJECT); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.fatal(() -> OBJECT, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.fatal(MARKER, () -> OBJECT); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.fatal(MARKER, () -> OBJECT, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.fatal(STRING, SUPPLIERS); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.fatal(MARKER, STRING, SUPPLIERS); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); } public void testError(final ListAppender app) { app.clear(); final String methodName = "testError"; - int lineNumber = getLineNumber(); // current line number logger.error(CHAR_SEQUENCE); - assertLocationEquals(methodName, ++lineNumber, app); + assertLocationEquals(methodName, app); logger.error(CHAR_SEQUENCE, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.error(MARKER, CHAR_SEQUENCE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.error(MARKER, CHAR_SEQUENCE, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.error(MESSAGE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.error(MESSAGE, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.error(MARKER, MESSAGE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.error(MARKER, MESSAGE, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.error(OBJECT); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.error(OBJECT, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.error(MARKER, OBJECT); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.error(MARKER, OBJECT, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.error(STRING); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.error(MARKER, STRING); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.error(STRING, P0); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.error(MARKER, STRING, P0); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.error(STRING, P0, P1); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.error(MARKER, STRING, P0, P1); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.error(STRING, P0, P1, P2); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.error(MARKER, STRING, P0, P1, P2); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.error(STRING, P0, P1, P2, P3); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.error(MARKER, STRING, P0, P1, P2, P3); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.error(STRING, P0, P1, P2, P3, P4); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.error(MARKER, STRING, P0, P1, P2, P3, P4); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.error(STRING, P0, P1, P2, P3, P4, P5); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.error(MARKER, STRING, P0, P1, P2, P3, P4, P5); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.error(STRING, P0, P1, P2, P3, P4, P5, P6); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.error(MARKER, STRING, P0, P1, P2, P3, P4, P5, P6); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.error(STRING, P0, P1, P2, P3, P4, P5, P6, P7); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.error(MARKER, STRING, P0, P1, P2, P3, P4, P5, P6, P7); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.error(STRING, P0, P1, P2, P3, P4, P5, P6, P7, P8); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.error(MARKER, STRING, P0, P1, P2, P3, P4, P5, P6, P7, P8); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.error(STRING, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.error(MARKER, STRING, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.error(STRING, PARRAY); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.error(MARKER, STRING, PARRAY); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.error(() -> MESSAGE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.error(() -> MESSAGE, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.error(MARKER, () -> MESSAGE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.error(MARKER, () -> MESSAGE, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.error(() -> OBJECT); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.error(() -> OBJECT, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.error(MARKER, () -> OBJECT); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.error(MARKER, () -> OBJECT, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.error(STRING, SUPPLIERS); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.error(MARKER, STRING, SUPPLIERS); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); } public void testWarn(final ListAppender app) { app.clear(); final String methodName = "testWarn"; - int lineNumber = getLineNumber(); // current line number logger.warn(CHAR_SEQUENCE); - assertLocationEquals(methodName, ++lineNumber, app); + assertLocationEquals(methodName, app); logger.warn(CHAR_SEQUENCE, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.warn(MARKER, CHAR_SEQUENCE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.warn(MARKER, CHAR_SEQUENCE, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.warn(MESSAGE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.warn(MESSAGE, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.warn(MARKER, MESSAGE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.warn(MARKER, MESSAGE, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.warn(OBJECT); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.warn(OBJECT, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.warn(MARKER, OBJECT); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.warn(MARKER, OBJECT, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.warn(STRING); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.warn(MARKER, STRING); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.warn(STRING, P0); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.warn(MARKER, STRING, P0); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.warn(STRING, P0, P1); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.warn(MARKER, STRING, P0, P1); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.warn(STRING, P0, P1, P2); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.warn(MARKER, STRING, P0, P1, P2); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.warn(STRING, P0, P1, P2, P3); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.warn(MARKER, STRING, P0, P1, P2, P3); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.warn(STRING, P0, P1, P2, P3, P4); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.warn(MARKER, STRING, P0, P1, P2, P3, P4); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.warn(STRING, P0, P1, P2, P3, P4, P5); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.warn(MARKER, STRING, P0, P1, P2, P3, P4, P5); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.warn(STRING, P0, P1, P2, P3, P4, P5, P6); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.warn(MARKER, STRING, P0, P1, P2, P3, P4, P5, P6); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.warn(STRING, P0, P1, P2, P3, P4, P5, P6, P7); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.warn(MARKER, STRING, P0, P1, P2, P3, P4, P5, P6, P7); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.warn(STRING, P0, P1, P2, P3, P4, P5, P6, P7, P8); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.warn(MARKER, STRING, P0, P1, P2, P3, P4, P5, P6, P7, P8); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.warn(STRING, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.warn(MARKER, STRING, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.warn(STRING, PARRAY); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.warn(MARKER, STRING, PARRAY); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.warn(() -> MESSAGE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.warn(() -> MESSAGE, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.warn(MARKER, () -> MESSAGE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.warn(MARKER, () -> MESSAGE, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.warn(() -> OBJECT); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.warn(() -> OBJECT, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.warn(MARKER, () -> OBJECT); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.warn(MARKER, () -> OBJECT, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.warn(STRING, SUPPLIERS); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.warn(MARKER, STRING, SUPPLIERS); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); } public void testInfo(final ListAppender app) { app.clear(); final String methodName = "testInfo"; - int lineNumber = getLineNumber(); // current line number logger.info(CHAR_SEQUENCE); - assertLocationEquals(methodName, ++lineNumber, app); + assertLocationEquals(methodName, app); logger.info(CHAR_SEQUENCE, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.info(MARKER, CHAR_SEQUENCE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.info(MARKER, CHAR_SEQUENCE, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.info(MESSAGE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.info(MESSAGE, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.info(MARKER, MESSAGE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.info(MARKER, MESSAGE, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.info(OBJECT); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.info(OBJECT, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.info(MARKER, OBJECT); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.info(MARKER, OBJECT, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.info(STRING); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.info(MARKER, STRING); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.info(STRING, P0); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.info(MARKER, STRING, P0); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.info(STRING, P0, P1); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.info(MARKER, STRING, P0, P1); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.info(STRING, P0, P1, P2); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.info(MARKER, STRING, P0, P1, P2); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.info(STRING, P0, P1, P2, P3); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.info(MARKER, STRING, P0, P1, P2, P3); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.info(STRING, P0, P1, P2, P3, P4); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.info(MARKER, STRING, P0, P1, P2, P3, P4); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.info(STRING, P0, P1, P2, P3, P4, P5); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.info(MARKER, STRING, P0, P1, P2, P3, P4, P5); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.info(STRING, P0, P1, P2, P3, P4, P5, P6); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.info(MARKER, STRING, P0, P1, P2, P3, P4, P5, P6); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.info(STRING, P0, P1, P2, P3, P4, P5, P6, P7); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.info(MARKER, STRING, P0, P1, P2, P3, P4, P5, P6, P7); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.info(STRING, P0, P1, P2, P3, P4, P5, P6, P7, P8); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.info(MARKER, STRING, P0, P1, P2, P3, P4, P5, P6, P7, P8); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.info(STRING, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.info(MARKER, STRING, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.info(STRING, PARRAY); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.info(MARKER, STRING, PARRAY); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.info(() -> MESSAGE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.info(() -> MESSAGE, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.info(MARKER, () -> MESSAGE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.info(MARKER, () -> MESSAGE, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.info(() -> OBJECT); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.info(() -> OBJECT, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.info(MARKER, () -> OBJECT); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.info(MARKER, () -> OBJECT, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.info(STRING, SUPPLIERS); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.info(MARKER, STRING, SUPPLIERS); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); } public void testDebug(final ListAppender app) { app.clear(); final String methodName = "testDebug"; - int lineNumber = getLineNumber(); // current line number logger.debug(CHAR_SEQUENCE); - assertLocationEquals(methodName, ++lineNumber, app); + assertLocationEquals(methodName, app); logger.debug(CHAR_SEQUENCE, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.debug(MARKER, CHAR_SEQUENCE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.debug(MARKER, CHAR_SEQUENCE, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.debug(MESSAGE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.debug(MESSAGE, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.debug(MARKER, MESSAGE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.debug(MARKER, MESSAGE, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.debug(OBJECT); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.debug(OBJECT, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.debug(MARKER, OBJECT); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.debug(MARKER, OBJECT, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.debug(STRING); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.debug(MARKER, STRING); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.debug(STRING, P0); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.debug(MARKER, STRING, P0); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.debug(STRING, P0, P1); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.debug(MARKER, STRING, P0, P1); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.debug(STRING, P0, P1, P2); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.debug(MARKER, STRING, P0, P1, P2); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.debug(STRING, P0, P1, P2, P3); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.debug(MARKER, STRING, P0, P1, P2, P3); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.debug(STRING, P0, P1, P2, P3, P4); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.debug(MARKER, STRING, P0, P1, P2, P3, P4); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.debug(STRING, P0, P1, P2, P3, P4, P5); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.debug(MARKER, STRING, P0, P1, P2, P3, P4, P5); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.debug(STRING, P0, P1, P2, P3, P4, P5, P6); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.debug(MARKER, STRING, P0, P1, P2, P3, P4, P5, P6); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.debug(STRING, P0, P1, P2, P3, P4, P5, P6, P7); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.debug(MARKER, STRING, P0, P1, P2, P3, P4, P5, P6, P7); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.debug(STRING, P0, P1, P2, P3, P4, P5, P6, P7, P8); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.debug(MARKER, STRING, P0, P1, P2, P3, P4, P5, P6, P7, P8); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.debug(STRING, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.debug(MARKER, STRING, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.debug(STRING, PARRAY); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.debug(MARKER, STRING, PARRAY); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.debug(() -> MESSAGE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.debug(() -> MESSAGE, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.debug(MARKER, () -> MESSAGE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.debug(MARKER, () -> MESSAGE, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.debug(() -> OBJECT); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.debug(() -> OBJECT, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.debug(MARKER, () -> OBJECT); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.debug(MARKER, () -> OBJECT, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.debug(STRING, SUPPLIERS); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.debug(MARKER, STRING, SUPPLIERS); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); } public void testTrace(final ListAppender app) { app.clear(); final String methodName = "testTrace"; - int lineNumber = getLineNumber(); // current line number logger.trace(CHAR_SEQUENCE); - assertLocationEquals(methodName, ++lineNumber, app); + assertLocationEquals(methodName, app); logger.trace(CHAR_SEQUENCE, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.trace(MARKER, CHAR_SEQUENCE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.trace(MARKER, CHAR_SEQUENCE, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.trace(MESSAGE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.trace(MESSAGE, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.trace(MARKER, MESSAGE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.trace(MARKER, MESSAGE, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.trace(OBJECT); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.trace(OBJECT, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.trace(MARKER, OBJECT); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.trace(MARKER, OBJECT, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.trace(STRING); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.trace(MARKER, STRING); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.trace(STRING, P0); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.trace(MARKER, STRING, P0); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.trace(STRING, P0, P1); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.trace(MARKER, STRING, P0, P1); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.trace(STRING, P0, P1, P2); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.trace(MARKER, STRING, P0, P1, P2); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.trace(STRING, P0, P1, P2, P3); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.trace(MARKER, STRING, P0, P1, P2, P3); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.trace(STRING, P0, P1, P2, P3, P4); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.trace(MARKER, STRING, P0, P1, P2, P3, P4); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.trace(STRING, P0, P1, P2, P3, P4, P5); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.trace(MARKER, STRING, P0, P1, P2, P3, P4, P5); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.trace(STRING, P0, P1, P2, P3, P4, P5, P6); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.trace(MARKER, STRING, P0, P1, P2, P3, P4, P5, P6); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.trace(STRING, P0, P1, P2, P3, P4, P5, P6, P7); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.trace(MARKER, STRING, P0, P1, P2, P3, P4, P5, P6, P7); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.trace(STRING, P0, P1, P2, P3, P4, P5, P6, P7, P8); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.trace(MARKER, STRING, P0, P1, P2, P3, P4, P5, P6, P7, P8); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.trace(STRING, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.trace(MARKER, STRING, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.trace(STRING, PARRAY); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.trace(MARKER, STRING, PARRAY); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.trace(() -> MESSAGE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.trace(() -> MESSAGE, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.trace(MARKER, () -> MESSAGE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.trace(MARKER, () -> MESSAGE, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.trace(() -> OBJECT); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.trace(() -> OBJECT, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.trace(MARKER, () -> OBJECT); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.trace(MARKER, () -> OBJECT, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.trace(STRING, SUPPLIERS); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.trace(MARKER, STRING, SUPPLIERS); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); } public void testLog(final ListAppender app) { app.clear(); final String methodName = "testLog"; - int lineNumber = getLineNumber(); // current line number logger.log(Level.INFO, CHAR_SEQUENCE); - assertLocationEquals(methodName, ++lineNumber, app); + assertLocationEquals(methodName, app); logger.log(Level.INFO, CHAR_SEQUENCE, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.log(Level.INFO, MARKER, CHAR_SEQUENCE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.log(Level.INFO, MARKER, CHAR_SEQUENCE, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.log(Level.INFO, MESSAGE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.log(Level.INFO, MESSAGE, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.log(Level.INFO, MARKER, MESSAGE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.log(Level.INFO, MARKER, MESSAGE, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.log(Level.INFO, OBJECT); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.log(Level.INFO, OBJECT, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.log(Level.INFO, MARKER, OBJECT); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.log(Level.INFO, MARKER, OBJECT, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.log(Level.INFO, STRING); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.log(Level.INFO, MARKER, STRING); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.log(Level.INFO, STRING, P0); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.log(Level.INFO, MARKER, STRING, P0); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.log(Level.INFO, STRING, P0, P1); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.log(Level.INFO, MARKER, STRING, P0, P1); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.log(Level.INFO, STRING, P0, P1, P2); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.log(Level.INFO, MARKER, STRING, P0, P1, P2); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.log(Level.INFO, STRING, P0, P1, P2, P3); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.log(Level.INFO, MARKER, STRING, P0, P1, P2, P3); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.log(Level.INFO, STRING, P0, P1, P2, P3, P4); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.log(Level.INFO, MARKER, STRING, P0, P1, P2, P3, P4); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.log(Level.INFO, STRING, P0, P1, P2, P3, P4, P5); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.log(Level.INFO, MARKER, STRING, P0, P1, P2, P3, P4, P5); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.log(Level.INFO, STRING, P0, P1, P2, P3, P4, P5, P6); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.log(Level.INFO, MARKER, STRING, P0, P1, P2, P3, P4, P5, P6); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.log(Level.INFO, STRING, P0, P1, P2, P3, P4, P5, P6, P7); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.log(Level.INFO, MARKER, STRING, P0, P1, P2, P3, P4, P5, P6, P7); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.log(Level.INFO, STRING, P0, P1, P2, P3, P4, P5, P6, P7, P8); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.log(Level.INFO, MARKER, STRING, P0, P1, P2, P3, P4, P5, P6, P7, P8); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.log(Level.INFO, STRING, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.log(Level.INFO, MARKER, STRING, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.log(Level.INFO, STRING, PARRAY); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.log(Level.INFO, MARKER, STRING, PARRAY); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.log(Level.INFO, () -> MESSAGE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.log(Level.INFO, () -> MESSAGE, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.log(Level.INFO, MARKER, () -> MESSAGE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.log(Level.INFO, MARKER, () -> MESSAGE, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.log(Level.INFO, () -> OBJECT); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.log(Level.INFO, () -> OBJECT, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.log(Level.INFO, MARKER, () -> OBJECT); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.log(Level.INFO, MARKER, () -> OBJECT, THROWABLE); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.log(Level.INFO, STRING, SUPPLIERS); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.log(Level.INFO, MARKER, STRING, SUPPLIERS); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); } public void testFrames(final ListAppender app) { app.clear(); final String methodName = "testFrames"; - final int lineNumber = getLineNumber(); // Current line int i = 0; while (i < 2) { if (i < 1) { logger.debug(OBJECT); - assertLocationEquals(methodName, lineNumber + 4, app); + assertLocationEquals(methodName, app); } else { logger.debug(OBJECT); - assertLocationEquals(methodName, lineNumber + 7, app); + assertLocationEquals(methodName, app); } logger.debug(OBJECT); - assertLocationEquals(methodName, lineNumber + 10, app); + assertLocationEquals(methodName, app); i++; } switch (i) { case 2: logger.debug(OBJECT); - assertLocationEquals(methodName, lineNumber + 16, app); + assertLocationEquals(methodName, app); break; } for (; i >= 0; i--) { logger.debug(OBJECT); - assertLocationEquals(methodName, lineNumber + 21, app); + assertLocationEquals(methodName, app); } } public void testPrintf(final ListAppender app) { app.clear(); final String methodName = "testPrintf"; - int lineNumber = getLineNumber(); // Current line logger.printf(Level.INFO, "Hello %s.%s", "LoggerConversionHandlerExample", methodName); - assertLocationEquals(methodName, ++lineNumber, app); + assertLocationEquals(methodName, app); logger.printf(Level.INFO, MARKER, "Hello %s.%s", "LoggerConversionHandlerExample", methodName); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); } public void testLogBuilder(final ListAppender app) { app.clear(); final String methodName = "testLogBuilder"; - int lineNumber = getLineNumber(); // Current line logger.always().log(); - assertLocationEquals(methodName, ++lineNumber, app); + assertLocationEquals(methodName, app); logger.atDebug().log(); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.atError().log(); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.atFatal().log(); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.atInfo().log(); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.atLevel(Level.INFO).log(); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.atTrace().log(); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); logger.atWarn().log(); - assertLocationEquals(methodName, lineNumber += 2, app); + assertLocationEquals(methodName, app); } /** @@ -840,47 +830,45 @@ public void testPassthrough(final ListAppender app) { public void testCatchingThrowing(final ListAppender app) { app.clear(); final String methodName = "testCatchingThrowing"; - int lineNumber = getLineNumber(); // Current line logger.catching(THROWABLE); assertThat(app.getEvents()).allMatch(event -> AbstractLogger.CATCHING_MARKER.equals(event.getMarker())); - assertLocationEquals(methodName, ++lineNumber, app); + assertLocationEquals(methodName, app, 2); logger.catching(Level.INFO, THROWABLE); assertThat(app.getEvents()).allMatch(event -> AbstractLogger.CATCHING_MARKER.equals(event.getMarker())); - assertLocationEquals(methodName, lineNumber += 3, app); + assertLocationEquals(methodName, app, 2); assertThat(logger.throwing(THROWABLE)).isInstanceOf(RuntimeException.class); assertThat(app.getEvents()).allMatch(event -> AbstractLogger.THROWING_MARKER.equals(event.getMarker())); - assertLocationEquals(methodName, lineNumber += 3, app); + assertLocationEquals(methodName, app, 2); assertThat(logger.throwing(THROWABLE)).isInstanceOf(RuntimeException.class); assertThat(app.getEvents()).allMatch(event -> AbstractLogger.THROWING_MARKER.equals(event.getMarker())); - assertLocationEquals(methodName, lineNumber += 3, app); + assertLocationEquals(methodName, app, 2); } public void testTraceEntry(final ListAppender app) { app.clear(); final String methodName = "testTraceEntry"; - int lineNumber = getLineNumber(); // Current line EntryMessage entryMessage = logger.traceEntry(); - LogEvent event = assertLocationEquals(methodName, ++lineNumber, app); + LogEvent event = assertLocationEquals(methodName, app); assertThat(event.getMarker()).isEqualTo(AbstractLogger.ENTRY_MARKER); assertThat(entryMessage.getMessage()).isNull(); entryMessage = logger.traceEntry(MESSAGE); - event = assertLocationEquals(methodName, lineNumber += 5, app); + event = assertLocationEquals(methodName, app); assertThat(event.getMarker()).isEqualTo(AbstractLogger.ENTRY_MARKER); assertThat(entryMessage.getMessage()).isEqualTo(MESSAGE); entryMessage = logger.traceEntry("param1 = {}", PARRAY); - event = assertLocationEquals(methodName, lineNumber += 5, app); + event = assertLocationEquals(methodName, app); assertThat(event.getMarker()).isEqualTo(AbstractLogger.ENTRY_MARKER); assertThat(entryMessage.getFormattedMessage()).isEqualTo("Enter param1 = (...)"); entryMessage = logger.traceEntry(() -> P0, () -> P1); - event = assertLocationEquals(methodName, lineNumber += 5, app); + event = assertLocationEquals(methodName, app); assertThat(event.getMarker()).isEqualTo(AbstractLogger.ENTRY_MARKER); assertThat(entryMessage.getFormattedMessage()).isEqualTo("Enter params((p0), (p1))"); entryMessage = logger.traceEntry("param1 = {}, param2 = {}", () -> P0, () -> P1); - event = assertLocationEquals(methodName, lineNumber += 5, app); + event = assertLocationEquals(methodName, app); assertThat(event.getMarker()).isEqualTo(AbstractLogger.ENTRY_MARKER); assertThat(entryMessage.getFormattedMessage()).isEqualTo("Enter param1 = (p0), param2 = (p1)"); } @@ -888,50 +876,69 @@ public void testTraceEntry(final ListAppender app) { public void testTraceExit(final ListAppender app) { app.clear(); final String methodName = "testTraceExit"; - int lineNumber = getLineNumber(); // Current line logger.traceExit(); - LogEvent event = assertLocationEquals(methodName, ++lineNumber, app); + LogEvent event = assertLocationEquals(methodName, app); assertThat(event.getMarker()).isEqualTo(AbstractLogger.EXIT_MARKER); assertThat(event.getMessage()).isInstanceOf(ExitMessage.class); assertThat(event.getMessage().getFormattedMessage()).isEqualTo("Exit"); logger.traceExit(ENTRY_MESSAGE); - event = assertLocationEquals(methodName, lineNumber += 6, app); + event = assertLocationEquals(methodName, app); assertThat(event.getMarker()).isEqualTo(AbstractLogger.EXIT_MARKER); assertThat(event.getMessage()).isInstanceOf(ExitMessage.class); assertThat(event.getMessage().getFormattedMessage()).isEqualTo("Exit (Message)"); Object result = logger.traceExit(OBJECT); assertThat(result).isSameAs(OBJECT); - event = assertLocationEquals(methodName, lineNumber += 6, app); + event = assertLocationEquals(methodName, app, 2); assertThat(event.getMarker()).isEqualTo(AbstractLogger.EXIT_MARKER); assertThat(event.getMessage()).isInstanceOf(ExitMessage.class); assertThat(event.getMessage().getFormattedMessage()).isEqualTo("Exit with((Object))"); result = logger.traceExit("result = {}", OBJECT); assertThat(result).isSameAs(OBJECT); - event = assertLocationEquals(methodName, lineNumber += 7, app); + event = assertLocationEquals(methodName, app, 2); assertThat(event.getMarker()).isEqualTo(AbstractLogger.EXIT_MARKER); assertThat(event.getMessage()).isInstanceOf(ExitMessage.class); assertThat(event.getMessage().getFormattedMessage()).isEqualTo("Exit result = (Object)"); result = logger.traceExit(MESSAGE, OBJECT); assertThat(result).isSameAs(OBJECT); - event = assertLocationEquals(methodName, lineNumber += 7, app); + event = assertLocationEquals(methodName, app, 2); assertThat(event.getMarker()).isEqualTo(AbstractLogger.EXIT_MARKER); assertThat(event.getMessage()).isInstanceOf(ExitMessage.class); assertThat(event.getMessage().getFormattedMessage()).isEqualTo("Exit (Message): (Object)"); result = logger.traceExit(ENTRY_MESSAGE, OBJECT); assertThat(result).isSameAs(OBJECT); - event = assertLocationEquals(methodName, lineNumber += 7, app); + event = assertLocationEquals(methodName, app, 2); assertThat(event.getMarker()).isEqualTo(AbstractLogger.EXIT_MARKER); assertThat(event.getMessage()).isInstanceOf(ExitMessage.class); assertThat(event.getMessage().getFormattedMessage()).isEqualTo("Exit (Message): (Object)"); } + /** + * Asserts log event has the right location intended, the log request should right before this call + * + * @param methodName method name of the calling function + * @param app list appender + * @return the log event extracted + */ + private static LogEvent assertLocationEquals(final String methodName, final ListAppender app) { + return assertLocationEquals(methodName, app, -1); + } + + + /** + * Asserts log event has the right location intended, the log request is {@param difference} before this call + * + * @param methodName method name of the calling function + * @param app list appender + * @param difference the difference between the call to this function and the log + * @return the log event extracted + */ private static LogEvent assertLocationEquals( - final String methodName, final int lineNumber, final ListAppender app) { + final String methodName, final ListAppender app, int difference) { final List events = app.getEvents(); assertThat(events).hasSize(1); final LogEvent event = events.get(0); @@ -941,12 +948,16 @@ private static LogEvent assertLocationEquals( assertThat(location.getClassName()).isEqualTo(LoggerConversionHandlerExample.class.getName()); assertThat(location.getMethodName()).isEqualTo(methodName); assertThat(location.getFileName()).isEqualTo("LoggerConversionHandlerExample.java"); - assertThat(location.getLineNumber()).isEqualTo(lineNumber); + if (difference < 0) { + assertThat(location.getLineNumber()).isEqualTo(getCallerLineNumber(true) - 1); + } else { + assertThat(location.getLineNumber()).isEqualTo(getCallerLineNumber(false) - difference); + } app.clear(); return event; } - private static int getLineNumber() { - return Thread.currentThread().getStackTrace()[2].getLineNumber(); + private static int getCallerLineNumber(boolean isNested) { + return Thread.currentThread().getStackTrace()[3 + (isNested ? 1 : 0)].getLineNumber(); } } From 5b56d8b19d85bc51bf4dd95cdd7d7fee1ebc6c7c Mon Sep 17 00:00:00 2001 From: Omer Atzmon Date: Sun, 7 Sep 2025 22:45:32 +0300 Subject: [PATCH 4/4] spotless --- .../log4j/weaver/log4j2/LoggerConversionHandlerExample.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/log4j-weaver/src/test/java/org/apache/logging/log4j/weaver/log4j2/LoggerConversionHandlerExample.java b/log4j-weaver/src/test/java/org/apache/logging/log4j/weaver/log4j2/LoggerConversionHandlerExample.java index 90da230e..ae8ae598 100644 --- a/log4j-weaver/src/test/java/org/apache/logging/log4j/weaver/log4j2/LoggerConversionHandlerExample.java +++ b/log4j-weaver/src/test/java/org/apache/logging/log4j/weaver/log4j2/LoggerConversionHandlerExample.java @@ -928,7 +928,6 @@ private static LogEvent assertLocationEquals(final String methodName, final List return assertLocationEquals(methodName, app, -1); } - /** * Asserts log event has the right location intended, the log request is {@param difference} before this call * @@ -937,8 +936,7 @@ private static LogEvent assertLocationEquals(final String methodName, final List * @param difference the difference between the call to this function and the log * @return the log event extracted */ - private static LogEvent assertLocationEquals( - final String methodName, final ListAppender app, int difference) { + private static LogEvent assertLocationEquals(final String methodName, final ListAppender app, int difference) { final List events = app.getEvents(); assertThat(events).hasSize(1); final LogEvent event = events.get(0);