From 27de8b5aace8f99af503b7e423cb834f3af53ad6 Mon Sep 17 00:00:00 2001 From: Ladislav Thon Date: Tue, 30 May 2023 16:43:45 +0200 Subject: [PATCH] Logging with Panache: allow usage in tests outside of Quarkus --- core/runtime/pom.xml | 6 + .../src/main/java/io/quarkus/logging/Log.java | 627 ++++++++++++------ .../java/io/quarkus/logging/GenerateLog.java | 141 ++-- .../logging/LoggingApiCompletenessTest.java | 6 +- .../quarkus/logging/GenerateAllLogUsages.java | 3 +- .../io/quarkus/logging/GeneratedBean.java | 154 ++--- .../logging/LoggingWithoutQuarkusTest.java | 10 + 7 files changed, 613 insertions(+), 334 deletions(-) create mode 100644 integration-tests/logging-panache/src/test/java/io/quarkus/logging/LoggingWithoutQuarkusTest.java diff --git a/core/runtime/pom.xml b/core/runtime/pom.xml index deaf5b01bf73f..156132a7679de 100644 --- a/core/runtime/pom.xml +++ b/core/runtime/pom.xml @@ -116,6 +116,12 @@ + + + com.github.javaparser + javaparser-core + test + org.junit.jupiter diff --git a/core/runtime/src/main/java/io/quarkus/logging/Log.java b/core/runtime/src/main/java/io/quarkus/logging/Log.java index 2c0132299f03b..135b391c2f79c 100644 --- a/core/runtime/src/main/java/io/quarkus/logging/Log.java +++ b/core/runtime/src/main/java/io/quarkus/logging/Log.java @@ -2,13 +2,26 @@ import org.jboss.logging.Logger; +// automatically generated by io.quarkus.logging.GenerateLog /** * Copy of {@link org.jboss.logging.BasicLogger}. * Invocations of all {@code static} methods of this class are, during build time, replaced by invocations * of the same methods on a generated instance of {@link Logger}. */ public final class Log { - // automatically generated by io.quarkus.logging.GenerateLog + + private static final StackWalker stackWalker = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE); + + private static final boolean shouldFail = !isTest(); + + private static boolean isTest() { + try { + Class.forName("org.junit.jupiter.api.Assertions"); + return true; + } catch (java.lang.ClassNotFoundException ignored) { + return false; + } + } /** * Check to see if the given level is enabled for this logger. @@ -17,10 +30,10 @@ public final class Log { * @return {@code true} if messages may be logged at the given level, {@code false} otherwise */ public static boolean isEnabled(Logger.Level level) { - if (always()) { + if (shouldFail) { throw fail(); } - return always(); + return Logger.getLogger(stackWalker.getCallerClass()).isEnabled(level); } /** @@ -30,10 +43,10 @@ public static boolean isEnabled(Logger.Level level) { * otherwise */ public static boolean isTraceEnabled() { - if (always()) { + if (shouldFail) { throw fail(); } - return always(); + return Logger.getLogger(stackWalker.getCallerClass()).isTraceEnabled(); } /** @@ -42,9 +55,10 @@ public static boolean isTraceEnabled() { * @param message the message */ public static void trace(Object message) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).trace(message); } /** @@ -54,9 +68,10 @@ public static void trace(Object message) { * @param t the throwable */ public static void trace(Object message, Throwable t) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).trace(message, t); } /** @@ -67,9 +82,10 @@ public static void trace(Object message, Throwable t) { * @param t the throwable */ public static void trace(String loggerFqcn, Object message, Throwable t) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).trace(loggerFqcn, message, t); } /** @@ -81,9 +97,10 @@ public static void trace(String loggerFqcn, Object message, Throwable t) { * @param t the throwable */ public static void trace(String loggerFqcn, Object message, Object[] params, Throwable t) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).trace(loggerFqcn, message, params, t); } /** @@ -93,9 +110,10 @@ public static void trace(String loggerFqcn, Object message, Object[] params, Thr * @param params the parameters */ public static void tracev(String format, Object... params) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).tracev(format, params); } /** @@ -105,9 +123,10 @@ public static void tracev(String format, Object... params) { * @param param1 the sole parameter */ public static void tracev(String format, Object param1) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).tracev(format, param1); } /** @@ -118,9 +137,10 @@ public static void tracev(String format, Object param1) { * @param param2 the second parameter */ public static void tracev(String format, Object param1, Object param2) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).tracev(format, param1, param2); } /** @@ -132,9 +152,10 @@ public static void tracev(String format, Object param1, Object param2) { * @param param3 the third parameter */ public static void tracev(String format, Object param1, Object param2, Object param3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).tracev(format, param1, param2, param3); } /** @@ -145,9 +166,10 @@ public static void tracev(String format, Object param1, Object param2, Object pa * @param params the parameters */ public static void tracev(Throwable t, String format, Object... params) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).tracev(t, format, params); } /** @@ -158,9 +180,10 @@ public static void tracev(Throwable t, String format, Object... params) { * @param param1 the sole parameter */ public static void tracev(Throwable t, String format, Object param1) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).tracev(t, format, param1); } /** @@ -172,9 +195,10 @@ public static void tracev(Throwable t, String format, Object param1) { * @param param2 the second parameter */ public static void tracev(Throwable t, String format, Object param1, Object param2) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).tracev(t, format, param1, param2); } /** @@ -187,9 +211,10 @@ public static void tracev(Throwable t, String format, Object param1, Object para * @param param3 the third parameter */ public static void tracev(Throwable t, String format, Object param1, Object param2, Object param3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).tracev(t, format, param1, param2, param3); } /** @@ -199,9 +224,10 @@ public static void tracev(Throwable t, String format, Object param1, Object para * @param params the parameters */ public static void tracef(String format, Object... params) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).tracef(format, params); } /** @@ -211,9 +237,10 @@ public static void tracef(String format, Object... params) { * @param param1 the sole parameter */ public static void tracef(String format, Object param1) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).tracef(format, param1); } /** @@ -224,9 +251,10 @@ public static void tracef(String format, Object param1) { * @param param2 the second parameter */ public static void tracef(String format, Object param1, Object param2) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).tracef(format, param1, param2); } /** @@ -238,9 +266,10 @@ public static void tracef(String format, Object param1, Object param2) { * @param param3 the third parameter */ public static void tracef(String format, Object param1, Object param2, Object param3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).tracef(format, param1, param2, param3); } /** @@ -251,9 +280,10 @@ public static void tracef(String format, Object param1, Object param2, Object pa * @param params the parameters */ public static void tracef(Throwable t, String format, Object... params) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).tracef(t, format, params); } /** @@ -264,9 +294,10 @@ public static void tracef(Throwable t, String format, Object... params) { * @param param1 the sole parameter */ public static void tracef(Throwable t, String format, Object param1) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).tracef(t, format, param1); } /** @@ -278,9 +309,10 @@ public static void tracef(Throwable t, String format, Object param1) { * @param param2 the second parameter */ public static void tracef(Throwable t, String format, Object param1, Object param2) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).tracef(t, format, param1, param2); } /** @@ -293,9 +325,10 @@ public static void tracef(Throwable t, String format, Object param1, Object para * @param param3 the third parameter */ public static void tracef(Throwable t, String format, Object param1, Object param2, Object param3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).tracef(t, format, param1, param2, param3); } /** @@ -305,9 +338,10 @@ public static void tracef(Throwable t, String format, Object param1, Object para * @param arg the parameter */ public static void tracef(String format, int arg) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).tracef(format, arg); } /** @@ -318,9 +352,10 @@ public static void tracef(String format, int arg) { * @param arg2 the second parameter */ public static void tracef(String format, int arg1, int arg2) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).tracef(format, arg1, arg2); } /** @@ -331,9 +366,10 @@ public static void tracef(String format, int arg1, int arg2) { * @param arg2 the second parameter */ public static void tracef(String format, int arg1, Object arg2) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).tracef(format, arg1, arg2); } /** @@ -345,9 +381,10 @@ public static void tracef(String format, int arg1, Object arg2) { * @param arg3 the third parameter */ public static void tracef(String format, int arg1, int arg2, int arg3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).tracef(format, arg1, arg2, arg3); } /** @@ -359,9 +396,10 @@ public static void tracef(String format, int arg1, int arg2, int arg3) { * @param arg3 the third parameter */ public static void tracef(String format, int arg1, int arg2, Object arg3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).tracef(format, arg1, arg2, arg3); } /** @@ -373,9 +411,10 @@ public static void tracef(String format, int arg1, int arg2, Object arg3) { * @param arg3 the third parameter */ public static void tracef(String format, int arg1, Object arg2, Object arg3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).tracef(format, arg1, arg2, arg3); } /** @@ -386,9 +425,10 @@ public static void tracef(String format, int arg1, Object arg2, Object arg3) { * @param arg the parameter */ public static void tracef(Throwable t, String format, int arg) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).tracef(t, format, arg); } /** @@ -400,9 +440,10 @@ public static void tracef(Throwable t, String format, int arg) { * @param arg2 the second parameter */ public static void tracef(Throwable t, String format, int arg1, int arg2) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).tracef(t, format, arg1, arg2); } /** @@ -414,9 +455,10 @@ public static void tracef(Throwable t, String format, int arg1, int arg2) { * @param arg2 the second parameter */ public static void tracef(Throwable t, String format, int arg1, Object arg2) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).tracef(t, format, arg1, arg2); } /** @@ -429,9 +471,10 @@ public static void tracef(Throwable t, String format, int arg1, Object arg2) { * @param arg3 the third parameter */ public static void tracef(Throwable t, String format, int arg1, int arg2, int arg3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).tracef(t, format, arg1, arg2, arg3); } /** @@ -444,9 +487,10 @@ public static void tracef(Throwable t, String format, int arg1, int arg2, int ar * @param arg3 the third parameter */ public static void tracef(Throwable t, String format, int arg1, int arg2, Object arg3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).tracef(t, format, arg1, arg2, arg3); } /** @@ -459,9 +503,10 @@ public static void tracef(Throwable t, String format, int arg1, int arg2, Object * @param arg3 the third parameter */ public static void tracef(Throwable t, String format, int arg1, Object arg2, Object arg3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).tracef(t, format, arg1, arg2, arg3); } /** @@ -471,9 +516,10 @@ public static void tracef(Throwable t, String format, int arg1, Object arg2, Obj * @param arg the parameter */ public static void tracef(String format, long arg) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).tracef(format, arg); } /** @@ -484,9 +530,10 @@ public static void tracef(String format, long arg) { * @param arg2 the second parameter */ public static void tracef(String format, long arg1, long arg2) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).tracef(format, arg1, arg2); } /** @@ -497,9 +544,10 @@ public static void tracef(String format, long arg1, long arg2) { * @param arg2 the second parameter */ public static void tracef(String format, long arg1, Object arg2) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).tracef(format, arg1, arg2); } /** @@ -511,9 +559,10 @@ public static void tracef(String format, long arg1, Object arg2) { * @param arg3 the third parameter */ public static void tracef(String format, long arg1, long arg2, long arg3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).tracef(format, arg1, arg2, arg3); } /** @@ -525,9 +574,10 @@ public static void tracef(String format, long arg1, long arg2, long arg3) { * @param arg3 the third parameter */ public static void tracef(String format, long arg1, long arg2, Object arg3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).tracef(format, arg1, arg2, arg3); } /** @@ -539,9 +589,10 @@ public static void tracef(String format, long arg1, long arg2, Object arg3) { * @param arg3 the third parameter */ public static void tracef(String format, long arg1, Object arg2, Object arg3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).tracef(format, arg1, arg2, arg3); } /** @@ -552,9 +603,10 @@ public static void tracef(String format, long arg1, Object arg2, Object arg3) { * @param arg the parameter */ public static void tracef(Throwable t, String format, long arg) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).tracef(t, format, arg); } /** @@ -566,9 +618,10 @@ public static void tracef(Throwable t, String format, long arg) { * @param arg2 the second parameter */ public static void tracef(Throwable t, String format, long arg1, long arg2) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).tracef(t, format, arg1, arg2); } /** @@ -580,9 +633,10 @@ public static void tracef(Throwable t, String format, long arg1, long arg2) { * @param arg2 the second parameter */ public static void tracef(Throwable t, String format, long arg1, Object arg2) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).tracef(t, format, arg1, arg2); } /** @@ -595,9 +649,10 @@ public static void tracef(Throwable t, String format, long arg1, Object arg2) { * @param arg3 the third parameter */ public static void tracef(Throwable t, String format, long arg1, long arg2, long arg3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).tracef(t, format, arg1, arg2, arg3); } /** @@ -610,9 +665,10 @@ public static void tracef(Throwable t, String format, long arg1, long arg2, long * @param arg3 the third parameter */ public static void tracef(Throwable t, String format, long arg1, long arg2, Object arg3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).tracef(t, format, arg1, arg2, arg3); } /** @@ -625,9 +681,10 @@ public static void tracef(Throwable t, String format, long arg1, long arg2, Obje * @param arg3 the third parameter */ public static void tracef(Throwable t, String format, long arg1, Object arg2, Object arg3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).tracef(t, format, arg1, arg2, arg3); } /** @@ -637,10 +694,10 @@ public static void tracef(Throwable t, String format, long arg1, Object arg2, Ob * otherwise */ public static boolean isDebugEnabled() { - if (always()) { + if (shouldFail) { throw fail(); } - return always(); + return Logger.getLogger(stackWalker.getCallerClass()).isDebugEnabled(); } /** @@ -649,9 +706,10 @@ public static boolean isDebugEnabled() { * @param message the message */ public static void debug(Object message) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).debug(message); } /** @@ -661,9 +719,10 @@ public static void debug(Object message) { * @param t the throwable */ public static void debug(Object message, Throwable t) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).debug(message, t); } /** @@ -674,9 +733,10 @@ public static void debug(Object message, Throwable t) { * @param t the throwable */ public static void debug(String loggerFqcn, Object message, Throwable t) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).debug(loggerFqcn, message, t); } /** @@ -688,9 +748,10 @@ public static void debug(String loggerFqcn, Object message, Throwable t) { * @param t the throwable */ public static void debug(String loggerFqcn, Object message, Object[] params, Throwable t) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).debug(loggerFqcn, message, params, t); } /** @@ -700,9 +761,10 @@ public static void debug(String loggerFqcn, Object message, Object[] params, Thr * @param params the parameters */ public static void debugv(String format, Object... params) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).debugv(format, params); } /** @@ -712,9 +774,10 @@ public static void debugv(String format, Object... params) { * @param param1 the sole parameter */ public static void debugv(String format, Object param1) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).debugv(format, param1); } /** @@ -725,9 +788,10 @@ public static void debugv(String format, Object param1) { * @param param2 the second parameter */ public static void debugv(String format, Object param1, Object param2) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).debugv(format, param1, param2); } /** @@ -739,9 +803,10 @@ public static void debugv(String format, Object param1, Object param2) { * @param param3 the third parameter */ public static void debugv(String format, Object param1, Object param2, Object param3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).debugv(format, param1, param2, param3); } /** @@ -752,9 +817,10 @@ public static void debugv(String format, Object param1, Object param2, Object pa * @param params the parameters */ public static void debugv(Throwable t, String format, Object... params) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).debugv(t, format, params); } /** @@ -765,9 +831,10 @@ public static void debugv(Throwable t, String format, Object... params) { * @param param1 the sole parameter */ public static void debugv(Throwable t, String format, Object param1) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).debugv(t, format, param1); } /** @@ -779,9 +846,10 @@ public static void debugv(Throwable t, String format, Object param1) { * @param param2 the second parameter */ public static void debugv(Throwable t, String format, Object param1, Object param2) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).debugv(t, format, param1, param2); } /** @@ -794,9 +862,10 @@ public static void debugv(Throwable t, String format, Object param1, Object para * @param param3 the third parameter */ public static void debugv(Throwable t, String format, Object param1, Object param2, Object param3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).debugv(t, format, param1, param2, param3); } /** @@ -806,9 +875,10 @@ public static void debugv(Throwable t, String format, Object param1, Object para * @param params the parameters */ public static void debugf(String format, Object... params) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).debugf(format, params); } /** @@ -818,9 +888,10 @@ public static void debugf(String format, Object... params) { * @param param1 the sole parameter */ public static void debugf(String format, Object param1) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).debugf(format, param1); } /** @@ -831,9 +902,10 @@ public static void debugf(String format, Object param1) { * @param param2 the second parameter */ public static void debugf(String format, Object param1, Object param2) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).debugf(format, param1, param2); } /** @@ -845,9 +917,10 @@ public static void debugf(String format, Object param1, Object param2) { * @param param3 the third parameter */ public static void debugf(String format, Object param1, Object param2, Object param3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).debugf(format, param1, param2, param3); } /** @@ -858,9 +931,10 @@ public static void debugf(String format, Object param1, Object param2, Object pa * @param params the parameters */ public static void debugf(Throwable t, String format, Object... params) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).debugf(t, format, params); } /** @@ -871,9 +945,10 @@ public static void debugf(Throwable t, String format, Object... params) { * @param param1 the sole parameter */ public static void debugf(Throwable t, String format, Object param1) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).debugf(t, format, param1); } /** @@ -885,9 +960,10 @@ public static void debugf(Throwable t, String format, Object param1) { * @param param2 the second parameter */ public static void debugf(Throwable t, String format, Object param1, Object param2) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).debugf(t, format, param1, param2); } /** @@ -900,9 +976,10 @@ public static void debugf(Throwable t, String format, Object param1, Object para * @param param3 the third parameter */ public static void debugf(Throwable t, String format, Object param1, Object param2, Object param3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).debugf(t, format, param1, param2, param3); } /** @@ -912,9 +989,10 @@ public static void debugf(Throwable t, String format, Object param1, Object para * @param arg the parameter */ public static void debugf(String format, int arg) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).debugf(format, arg); } /** @@ -925,9 +1003,10 @@ public static void debugf(String format, int arg) { * @param arg2 the second parameter */ public static void debugf(String format, int arg1, int arg2) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).debugf(format, arg1, arg2); } /** @@ -938,9 +1017,10 @@ public static void debugf(String format, int arg1, int arg2) { * @param arg2 the second parameter */ public static void debugf(String format, int arg1, Object arg2) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).debugf(format, arg1, arg2); } /** @@ -952,9 +1032,10 @@ public static void debugf(String format, int arg1, Object arg2) { * @param arg3 the third parameter */ public static void debugf(String format, int arg1, int arg2, int arg3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).debugf(format, arg1, arg2, arg3); } /** @@ -966,9 +1047,10 @@ public static void debugf(String format, int arg1, int arg2, int arg3) { * @param arg3 the third parameter */ public static void debugf(String format, int arg1, int arg2, Object arg3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).debugf(format, arg1, arg2, arg3); } /** @@ -980,9 +1062,10 @@ public static void debugf(String format, int arg1, int arg2, Object arg3) { * @param arg3 the third parameter */ public static void debugf(String format, int arg1, Object arg2, Object arg3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).debugf(format, arg1, arg2, arg3); } /** @@ -993,9 +1076,10 @@ public static void debugf(String format, int arg1, Object arg2, Object arg3) { * @param arg the parameter */ public static void debugf(Throwable t, String format, int arg) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).debugf(t, format, arg); } /** @@ -1007,9 +1091,10 @@ public static void debugf(Throwable t, String format, int arg) { * @param arg2 the second parameter */ public static void debugf(Throwable t, String format, int arg1, int arg2) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).debugf(t, format, arg1, arg2); } /** @@ -1021,9 +1106,10 @@ public static void debugf(Throwable t, String format, int arg1, int arg2) { * @param arg2 the second parameter */ public static void debugf(Throwable t, String format, int arg1, Object arg2) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).debugf(t, format, arg1, arg2); } /** @@ -1036,9 +1122,10 @@ public static void debugf(Throwable t, String format, int arg1, Object arg2) { * @param arg3 the third parameter */ public static void debugf(Throwable t, String format, int arg1, int arg2, int arg3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).debugf(t, format, arg1, arg2, arg3); } /** @@ -1051,9 +1138,10 @@ public static void debugf(Throwable t, String format, int arg1, int arg2, int ar * @param arg3 the third parameter */ public static void debugf(Throwable t, String format, int arg1, int arg2, Object arg3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).debugf(t, format, arg1, arg2, arg3); } /** @@ -1066,9 +1154,10 @@ public static void debugf(Throwable t, String format, int arg1, int arg2, Object * @param arg3 the third parameter */ public static void debugf(Throwable t, String format, int arg1, Object arg2, Object arg3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).debugf(t, format, arg1, arg2, arg3); } /** @@ -1078,9 +1167,10 @@ public static void debugf(Throwable t, String format, int arg1, Object arg2, Obj * @param arg the parameter */ public static void debugf(String format, long arg) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).debugf(format, arg); } /** @@ -1091,9 +1181,10 @@ public static void debugf(String format, long arg) { * @param arg2 the second parameter */ public static void debugf(String format, long arg1, long arg2) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).debugf(format, arg1, arg2); } /** @@ -1104,9 +1195,10 @@ public static void debugf(String format, long arg1, long arg2) { * @param arg2 the second parameter */ public static void debugf(String format, long arg1, Object arg2) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).debugf(format, arg1, arg2); } /** @@ -1118,9 +1210,10 @@ public static void debugf(String format, long arg1, Object arg2) { * @param arg3 the third parameter */ public static void debugf(String format, long arg1, long arg2, long arg3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).debugf(format, arg1, arg2, arg3); } /** @@ -1132,9 +1225,10 @@ public static void debugf(String format, long arg1, long arg2, long arg3) { * @param arg3 the third parameter */ public static void debugf(String format, long arg1, long arg2, Object arg3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).debugf(format, arg1, arg2, arg3); } /** @@ -1146,9 +1240,10 @@ public static void debugf(String format, long arg1, long arg2, Object arg3) { * @param arg3 the third parameter */ public static void debugf(String format, long arg1, Object arg2, Object arg3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).debugf(format, arg1, arg2, arg3); } /** @@ -1159,9 +1254,10 @@ public static void debugf(String format, long arg1, Object arg2, Object arg3) { * @param arg the parameter */ public static void debugf(Throwable t, String format, long arg) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).debugf(t, format, arg); } /** @@ -1173,9 +1269,10 @@ public static void debugf(Throwable t, String format, long arg) { * @param arg2 the second parameter */ public static void debugf(Throwable t, String format, long arg1, long arg2) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).debugf(t, format, arg1, arg2); } /** @@ -1187,9 +1284,10 @@ public static void debugf(Throwable t, String format, long arg1, long arg2) { * @param arg2 the second parameter */ public static void debugf(Throwable t, String format, long arg1, Object arg2) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).debugf(t, format, arg1, arg2); } /** @@ -1202,9 +1300,10 @@ public static void debugf(Throwable t, String format, long arg1, Object arg2) { * @param arg3 the third parameter */ public static void debugf(Throwable t, String format, long arg1, long arg2, long arg3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).debugf(t, format, arg1, arg2, arg3); } /** @@ -1217,9 +1316,10 @@ public static void debugf(Throwable t, String format, long arg1, long arg2, long * @param arg3 the third parameter */ public static void debugf(Throwable t, String format, long arg1, long arg2, Object arg3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).debugf(t, format, arg1, arg2, arg3); } /** @@ -1232,9 +1332,10 @@ public static void debugf(Throwable t, String format, long arg1, long arg2, Obje * @param arg3 the third parameter */ public static void debugf(Throwable t, String format, long arg1, Object arg2, Object arg3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).debugf(t, format, arg1, arg2, arg3); } /** @@ -1244,10 +1345,10 @@ public static void debugf(Throwable t, String format, long arg1, Object arg2, Ob * otherwise */ public static boolean isInfoEnabled() { - if (always()) { + if (shouldFail) { throw fail(); } - return always(); + return Logger.getLogger(stackWalker.getCallerClass()).isInfoEnabled(); } /** @@ -1256,9 +1357,10 @@ public static boolean isInfoEnabled() { * @param message the message */ public static void info(Object message) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).info(message); } /** @@ -1268,9 +1370,10 @@ public static void info(Object message) { * @param t the throwable */ public static void info(Object message, Throwable t) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).info(message, t); } /** @@ -1281,9 +1384,10 @@ public static void info(Object message, Throwable t) { * @param t the throwable */ public static void info(String loggerFqcn, Object message, Throwable t) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).info(loggerFqcn, message, t); } /** @@ -1295,9 +1399,10 @@ public static void info(String loggerFqcn, Object message, Throwable t) { * @param t the throwable */ public static void info(String loggerFqcn, Object message, Object[] params, Throwable t) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).info(loggerFqcn, message, params, t); } /** @@ -1307,9 +1412,10 @@ public static void info(String loggerFqcn, Object message, Object[] params, Thro * @param params the parameters */ public static void infov(String format, Object... params) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).infov(format, params); } /** @@ -1319,9 +1425,10 @@ public static void infov(String format, Object... params) { * @param param1 the sole parameter */ public static void infov(String format, Object param1) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).infov(format, param1); } /** @@ -1332,9 +1439,10 @@ public static void infov(String format, Object param1) { * @param param2 the second parameter */ public static void infov(String format, Object param1, Object param2) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).infov(format, param1, param2); } /** @@ -1346,9 +1454,10 @@ public static void infov(String format, Object param1, Object param2) { * @param param3 the third parameter */ public static void infov(String format, Object param1, Object param2, Object param3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).infov(format, param1, param2, param3); } /** @@ -1359,9 +1468,10 @@ public static void infov(String format, Object param1, Object param2, Object par * @param params the parameters */ public static void infov(Throwable t, String format, Object... params) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).infov(t, format, params); } /** @@ -1372,9 +1482,10 @@ public static void infov(Throwable t, String format, Object... params) { * @param param1 the sole parameter */ public static void infov(Throwable t, String format, Object param1) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).infov(t, format, param1); } /** @@ -1386,9 +1497,10 @@ public static void infov(Throwable t, String format, Object param1) { * @param param2 the second parameter */ public static void infov(Throwable t, String format, Object param1, Object param2) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).infov(t, format, param1, param2); } /** @@ -1401,9 +1513,10 @@ public static void infov(Throwable t, String format, Object param1, Object param * @param param3 the third parameter */ public static void infov(Throwable t, String format, Object param1, Object param2, Object param3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).infov(t, format, param1, param2, param3); } /** @@ -1413,9 +1526,10 @@ public static void infov(Throwable t, String format, Object param1, Object param * @param params the parameters */ public static void infof(String format, Object... params) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).infof(format, params); } /** @@ -1425,9 +1539,10 @@ public static void infof(String format, Object... params) { * @param param1 the sole parameter */ public static void infof(String format, Object param1) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).infof(format, param1); } /** @@ -1438,9 +1553,10 @@ public static void infof(String format, Object param1) { * @param param2 the second parameter */ public static void infof(String format, Object param1, Object param2) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).infof(format, param1, param2); } /** @@ -1452,9 +1568,10 @@ public static void infof(String format, Object param1, Object param2) { * @param param3 the third parameter */ public static void infof(String format, Object param1, Object param2, Object param3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).infof(format, param1, param2, param3); } /** @@ -1465,9 +1582,10 @@ public static void infof(String format, Object param1, Object param2, Object par * @param params the parameters */ public static void infof(Throwable t, String format, Object... params) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).infof(t, format, params); } /** @@ -1478,9 +1596,10 @@ public static void infof(Throwable t, String format, Object... params) { * @param param1 the sole parameter */ public static void infof(Throwable t, String format, Object param1) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).infof(t, format, param1); } /** @@ -1492,9 +1611,10 @@ public static void infof(Throwable t, String format, Object param1) { * @param param2 the second parameter */ public static void infof(Throwable t, String format, Object param1, Object param2) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).infof(t, format, param1, param2); } /** @@ -1507,9 +1627,10 @@ public static void infof(Throwable t, String format, Object param1, Object param * @param param3 the third parameter */ public static void infof(Throwable t, String format, Object param1, Object param2, Object param3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).infof(t, format, param1, param2, param3); } /** @@ -1518,9 +1639,10 @@ public static void infof(Throwable t, String format, Object param1, Object param * @param message the message */ public static void warn(Object message) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).warn(message); } /** @@ -1530,9 +1652,10 @@ public static void warn(Object message) { * @param t the throwable */ public static void warn(Object message, Throwable t) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).warn(message, t); } /** @@ -1543,9 +1666,10 @@ public static void warn(Object message, Throwable t) { * @param t the throwable */ public static void warn(String loggerFqcn, Object message, Throwable t) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).warn(loggerFqcn, message, t); } /** @@ -1557,9 +1681,10 @@ public static void warn(String loggerFqcn, Object message, Throwable t) { * @param t the throwable */ public static void warn(String loggerFqcn, Object message, Object[] params, Throwable t) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).warn(loggerFqcn, message, params, t); } /** @@ -1569,9 +1694,10 @@ public static void warn(String loggerFqcn, Object message, Object[] params, Thro * @param params the parameters */ public static void warnv(String format, Object... params) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).warnv(format, params); } /** @@ -1581,9 +1707,10 @@ public static void warnv(String format, Object... params) { * @param param1 the sole parameter */ public static void warnv(String format, Object param1) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).warnv(format, param1); } /** @@ -1594,9 +1721,10 @@ public static void warnv(String format, Object param1) { * @param param2 the second parameter */ public static void warnv(String format, Object param1, Object param2) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).warnv(format, param1, param2); } /** @@ -1608,9 +1736,10 @@ public static void warnv(String format, Object param1, Object param2) { * @param param3 the third parameter */ public static void warnv(String format, Object param1, Object param2, Object param3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).warnv(format, param1, param2, param3); } /** @@ -1621,9 +1750,10 @@ public static void warnv(String format, Object param1, Object param2, Object par * @param params the parameters */ public static void warnv(Throwable t, String format, Object... params) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).warnv(t, format, params); } /** @@ -1634,9 +1764,10 @@ public static void warnv(Throwable t, String format, Object... params) { * @param param1 the sole parameter */ public static void warnv(Throwable t, String format, Object param1) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).warnv(t, format, param1); } /** @@ -1648,9 +1779,10 @@ public static void warnv(Throwable t, String format, Object param1) { * @param param2 the second parameter */ public static void warnv(Throwable t, String format, Object param1, Object param2) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).warnv(t, format, param1, param2); } /** @@ -1663,9 +1795,10 @@ public static void warnv(Throwable t, String format, Object param1, Object param * @param param3 the third parameter */ public static void warnv(Throwable t, String format, Object param1, Object param2, Object param3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).warnv(t, format, param1, param2, param3); } /** @@ -1675,9 +1808,10 @@ public static void warnv(Throwable t, String format, Object param1, Object param * @param params the parameters */ public static void warnf(String format, Object... params) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).warnf(format, params); } /** @@ -1687,9 +1821,10 @@ public static void warnf(String format, Object... params) { * @param param1 the sole parameter */ public static void warnf(String format, Object param1) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).warnf(format, param1); } /** @@ -1700,9 +1835,10 @@ public static void warnf(String format, Object param1) { * @param param2 the second parameter */ public static void warnf(String format, Object param1, Object param2) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).warnf(format, param1, param2); } /** @@ -1714,9 +1850,10 @@ public static void warnf(String format, Object param1, Object param2) { * @param param3 the third parameter */ public static void warnf(String format, Object param1, Object param2, Object param3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).warnf(format, param1, param2, param3); } /** @@ -1727,9 +1864,10 @@ public static void warnf(String format, Object param1, Object param2, Object par * @param params the parameters */ public static void warnf(Throwable t, String format, Object... params) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).warnf(t, format, params); } /** @@ -1740,9 +1878,10 @@ public static void warnf(Throwable t, String format, Object... params) { * @param param1 the sole parameter */ public static void warnf(Throwable t, String format, Object param1) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).warnf(t, format, param1); } /** @@ -1754,9 +1893,10 @@ public static void warnf(Throwable t, String format, Object param1) { * @param param2 the second parameter */ public static void warnf(Throwable t, String format, Object param1, Object param2) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).warnf(t, format, param1, param2); } /** @@ -1769,9 +1909,10 @@ public static void warnf(Throwable t, String format, Object param1, Object param * @param param3 the third parameter */ public static void warnf(Throwable t, String format, Object param1, Object param2, Object param3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).warnf(t, format, param1, param2, param3); } /** @@ -1780,9 +1921,10 @@ public static void warnf(Throwable t, String format, Object param1, Object param * @param message the message */ public static void error(Object message) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).error(message); } /** @@ -1792,9 +1934,10 @@ public static void error(Object message) { * @param t the throwable */ public static void error(Object message, Throwable t) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).error(message, t); } /** @@ -1805,9 +1948,10 @@ public static void error(Object message, Throwable t) { * @param t the throwable */ public static void error(String loggerFqcn, Object message, Throwable t) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).error(loggerFqcn, message, t); } /** @@ -1819,9 +1963,10 @@ public static void error(String loggerFqcn, Object message, Throwable t) { * @param t the throwable */ public static void error(String loggerFqcn, Object message, Object[] params, Throwable t) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).error(loggerFqcn, message, params, t); } /** @@ -1831,9 +1976,10 @@ public static void error(String loggerFqcn, Object message, Object[] params, Thr * @param params the parameters */ public static void errorv(String format, Object... params) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).errorv(format, params); } /** @@ -1843,9 +1989,10 @@ public static void errorv(String format, Object... params) { * @param param1 the sole parameter */ public static void errorv(String format, Object param1) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).errorv(format, param1); } /** @@ -1856,9 +2003,10 @@ public static void errorv(String format, Object param1) { * @param param2 the second parameter */ public static void errorv(String format, Object param1, Object param2) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).errorv(format, param1, param2); } /** @@ -1870,9 +2018,10 @@ public static void errorv(String format, Object param1, Object param2) { * @param param3 the third parameter */ public static void errorv(String format, Object param1, Object param2, Object param3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).errorv(format, param1, param2, param3); } /** @@ -1883,9 +2032,10 @@ public static void errorv(String format, Object param1, Object param2, Object pa * @param params the parameters */ public static void errorv(Throwable t, String format, Object... params) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).errorv(t, format, params); } /** @@ -1896,9 +2046,10 @@ public static void errorv(Throwable t, String format, Object... params) { * @param param1 the sole parameter */ public static void errorv(Throwable t, String format, Object param1) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).errorv(t, format, param1); } /** @@ -1910,9 +2061,10 @@ public static void errorv(Throwable t, String format, Object param1) { * @param param2 the second parameter */ public static void errorv(Throwable t, String format, Object param1, Object param2) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).errorv(t, format, param1, param2); } /** @@ -1925,9 +2077,10 @@ public static void errorv(Throwable t, String format, Object param1, Object para * @param param3 the third parameter */ public static void errorv(Throwable t, String format, Object param1, Object param2, Object param3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).errorv(t, format, param1, param2, param3); } /** @@ -1937,9 +2090,10 @@ public static void errorv(Throwable t, String format, Object param1, Object para * @param params the parameters */ public static void errorf(String format, Object... params) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).errorf(format, params); } /** @@ -1949,9 +2103,10 @@ public static void errorf(String format, Object... params) { * @param param1 the sole parameter */ public static void errorf(String format, Object param1) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).errorf(format, param1); } /** @@ -1962,9 +2117,10 @@ public static void errorf(String format, Object param1) { * @param param2 the second parameter */ public static void errorf(String format, Object param1, Object param2) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).errorf(format, param1, param2); } /** @@ -1976,9 +2132,10 @@ public static void errorf(String format, Object param1, Object param2) { * @param param3 the third parameter */ public static void errorf(String format, Object param1, Object param2, Object param3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).errorf(format, param1, param2, param3); } /** @@ -1989,9 +2146,10 @@ public static void errorf(String format, Object param1, Object param2, Object pa * @param params the parameters */ public static void errorf(Throwable t, String format, Object... params) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).errorf(t, format, params); } /** @@ -2002,9 +2160,10 @@ public static void errorf(Throwable t, String format, Object... params) { * @param param1 the sole parameter */ public static void errorf(Throwable t, String format, Object param1) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).errorf(t, format, param1); } /** @@ -2016,9 +2175,10 @@ public static void errorf(Throwable t, String format, Object param1) { * @param param2 the second parameter */ public static void errorf(Throwable t, String format, Object param1, Object param2) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).errorf(t, format, param1, param2); } /** @@ -2031,9 +2191,10 @@ public static void errorf(Throwable t, String format, Object param1, Object para * @param param3 the third parameter */ public static void errorf(Throwable t, String format, Object param1, Object param2, Object param3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).errorf(t, format, param1, param2, param3); } /** @@ -2042,9 +2203,10 @@ public static void errorf(Throwable t, String format, Object param1, Object para * @param message the message */ public static void fatal(Object message) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).fatal(message); } /** @@ -2054,9 +2216,10 @@ public static void fatal(Object message) { * @param t the throwable */ public static void fatal(Object message, Throwable t) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).fatal(message, t); } /** @@ -2067,9 +2230,10 @@ public static void fatal(Object message, Throwable t) { * @param t the throwable */ public static void fatal(String loggerFqcn, Object message, Throwable t) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).fatal(loggerFqcn, message, t); } /** @@ -2081,9 +2245,10 @@ public static void fatal(String loggerFqcn, Object message, Throwable t) { * @param t the throwable */ public static void fatal(String loggerFqcn, Object message, Object[] params, Throwable t) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).fatal(loggerFqcn, message, params, t); } /** @@ -2093,9 +2258,10 @@ public static void fatal(String loggerFqcn, Object message, Object[] params, Thr * @param params the parameters */ public static void fatalv(String format, Object... params) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).fatalv(format, params); } /** @@ -2105,9 +2271,10 @@ public static void fatalv(String format, Object... params) { * @param param1 the sole parameter */ public static void fatalv(String format, Object param1) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).fatalv(format, param1); } /** @@ -2118,9 +2285,10 @@ public static void fatalv(String format, Object param1) { * @param param2 the second parameter */ public static void fatalv(String format, Object param1, Object param2) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).fatalv(format, param1, param2); } /** @@ -2132,9 +2300,10 @@ public static void fatalv(String format, Object param1, Object param2) { * @param param3 the third parameter */ public static void fatalv(String format, Object param1, Object param2, Object param3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).fatalv(format, param1, param2, param3); } /** @@ -2145,9 +2314,10 @@ public static void fatalv(String format, Object param1, Object param2, Object pa * @param params the parameters */ public static void fatalv(Throwable t, String format, Object... params) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).fatalv(t, format, params); } /** @@ -2158,9 +2328,10 @@ public static void fatalv(Throwable t, String format, Object... params) { * @param param1 the sole parameter */ public static void fatalv(Throwable t, String format, Object param1) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).fatalv(t, format, param1); } /** @@ -2172,9 +2343,10 @@ public static void fatalv(Throwable t, String format, Object param1) { * @param param2 the second parameter */ public static void fatalv(Throwable t, String format, Object param1, Object param2) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).fatalv(t, format, param1, param2); } /** @@ -2187,9 +2359,10 @@ public static void fatalv(Throwable t, String format, Object param1, Object para * @param param3 the third parameter */ public static void fatalv(Throwable t, String format, Object param1, Object param2, Object param3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).fatalv(t, format, param1, param2, param3); } /** @@ -2199,9 +2372,10 @@ public static void fatalv(Throwable t, String format, Object param1, Object para * @param params the parameters */ public static void fatalf(String format, Object... params) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).fatalf(format, params); } /** @@ -2211,9 +2385,10 @@ public static void fatalf(String format, Object... params) { * @param param1 the sole parameter */ public static void fatalf(String format, Object param1) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).fatalf(format, param1); } /** @@ -2224,9 +2399,10 @@ public static void fatalf(String format, Object param1) { * @param param2 the second parameter */ public static void fatalf(String format, Object param1, Object param2) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).fatalf(format, param1, param2); } /** @@ -2238,9 +2414,10 @@ public static void fatalf(String format, Object param1, Object param2) { * @param param3 the third parameter */ public static void fatalf(String format, Object param1, Object param2, Object param3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).fatalf(format, param1, param2, param3); } /** @@ -2251,9 +2428,10 @@ public static void fatalf(String format, Object param1, Object param2, Object pa * @param params the parameters */ public static void fatalf(Throwable t, String format, Object... params) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).fatalf(t, format, params); } /** @@ -2264,9 +2442,10 @@ public static void fatalf(Throwable t, String format, Object... params) { * @param param1 the sole parameter */ public static void fatalf(Throwable t, String format, Object param1) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).fatalf(t, format, param1); } /** @@ -2278,9 +2457,10 @@ public static void fatalf(Throwable t, String format, Object param1) { * @param param2 the second parameter */ public static void fatalf(Throwable t, String format, Object param1, Object param2) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).fatalf(t, format, param1, param2); } /** @@ -2293,9 +2473,10 @@ public static void fatalf(Throwable t, String format, Object param1, Object para * @param param3 the third parameter */ public static void fatalf(Throwable t, String format, Object param1, Object param2, Object param3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).fatalf(t, format, param1, param2, param3); } /** @@ -2305,9 +2486,10 @@ public static void fatalf(Throwable t, String format, Object param1, Object para * @param message the message */ public static void log(Logger.Level level, Object message) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).log(level, message); } /** @@ -2318,9 +2500,10 @@ public static void log(Logger.Level level, Object message) { * @param t the throwable */ public static void log(Logger.Level level, Object message, Throwable t) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).log(level, message, t); } /** @@ -2332,9 +2515,10 @@ public static void log(Logger.Level level, Object message, Throwable t) { * @param t the throwable */ public static void log(Logger.Level level, String loggerFqcn, Object message, Throwable t) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).log(level, loggerFqcn, message, t); } /** @@ -2347,9 +2531,10 @@ public static void log(Logger.Level level, String loggerFqcn, Object message, Th * @param t the throwable */ public static void log(String loggerFqcn, Logger.Level level, Object message, Object[] params, Throwable t) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).log(loggerFqcn, level, message, params, t); } /** @@ -2360,9 +2545,10 @@ public static void log(String loggerFqcn, Logger.Level level, Object message, Ob * @param params the parameters */ public static void logv(Logger.Level level, String format, Object... params) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).logv(level, format, params); } /** @@ -2373,9 +2559,10 @@ public static void logv(Logger.Level level, String format, Object... params) { * @param param1 the sole parameter */ public static void logv(Logger.Level level, String format, Object param1) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).logv(level, format, param1); } /** @@ -2387,9 +2574,10 @@ public static void logv(Logger.Level level, String format, Object param1) { * @param param2 the second parameter */ public static void logv(Logger.Level level, String format, Object param1, Object param2) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).logv(level, format, param1, param2); } /** @@ -2402,9 +2590,10 @@ public static void logv(Logger.Level level, String format, Object param1, Object * @param param3 the third parameter */ public static void logv(Logger.Level level, String format, Object param1, Object param2, Object param3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).logv(level, format, param1, param2, param3); } /** @@ -2416,9 +2605,10 @@ public static void logv(Logger.Level level, String format, Object param1, Object * @param params the parameters */ public static void logv(Logger.Level level, Throwable t, String format, Object... params) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).logv(level, t, format, params); } /** @@ -2430,9 +2620,10 @@ public static void logv(Logger.Level level, Throwable t, String format, Object.. * @param param1 the sole parameter */ public static void logv(Logger.Level level, Throwable t, String format, Object param1) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).logv(level, t, format, param1); } /** @@ -2445,9 +2636,10 @@ public static void logv(Logger.Level level, Throwable t, String format, Object p * @param param2 the second parameter */ public static void logv(Logger.Level level, Throwable t, String format, Object param1, Object param2) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).logv(level, t, format, param1, param2); } /** @@ -2461,9 +2653,10 @@ public static void logv(Logger.Level level, Throwable t, String format, Object p * @param param3 the third parameter */ public static void logv(Logger.Level level, Throwable t, String format, Object param1, Object param2, Object param3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).logv(level, t, format, param1, param2, param3); } /** @@ -2476,9 +2669,10 @@ public static void logv(Logger.Level level, Throwable t, String format, Object p * @param params the parameters */ public static void logv(String loggerFqcn, Logger.Level level, Throwable t, String format, Object... params) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).logv(loggerFqcn, level, t, format, params); } /** @@ -2491,9 +2685,10 @@ public static void logv(String loggerFqcn, Logger.Level level, Throwable t, Stri * @param param1 the sole parameter */ public static void logv(String loggerFqcn, Logger.Level level, Throwable t, String format, Object param1) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).logv(loggerFqcn, level, t, format, param1); } /** @@ -2507,9 +2702,10 @@ public static void logv(String loggerFqcn, Logger.Level level, Throwable t, Stri * @param param2 the second parameter */ public static void logv(String loggerFqcn, Logger.Level level, Throwable t, String format, Object param1, Object param2) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).logv(loggerFqcn, level, t, format, param1, param2); } /** @@ -2525,9 +2721,10 @@ public static void logv(String loggerFqcn, Logger.Level level, Throwable t, Stri */ public static void logv(String loggerFqcn, Logger.Level level, Throwable t, String format, Object param1, Object param2, Object param3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).logv(loggerFqcn, level, t, format, param1, param2, param3); } /** @@ -2538,9 +2735,10 @@ public static void logv(String loggerFqcn, Logger.Level level, Throwable t, Stri * @param params the parameters */ public static void logf(Logger.Level level, String format, Object... params) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).logf(level, format, params); } /** @@ -2551,9 +2749,10 @@ public static void logf(Logger.Level level, String format, Object... params) { * @param param1 the sole parameter */ public static void logf(Logger.Level level, String format, Object param1) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).logf(level, format, param1); } /** @@ -2565,9 +2764,10 @@ public static void logf(Logger.Level level, String format, Object param1) { * @param param2 the second parameter */ public static void logf(Logger.Level level, String format, Object param1, Object param2) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).logf(level, format, param1, param2); } /** @@ -2580,9 +2780,10 @@ public static void logf(Logger.Level level, String format, Object param1, Object * @param param3 the third parameter */ public static void logf(Logger.Level level, String format, Object param1, Object param2, Object param3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).logf(level, format, param1, param2, param3); } /** @@ -2594,9 +2795,10 @@ public static void logf(Logger.Level level, String format, Object param1, Object * @param params the parameters */ public static void logf(Logger.Level level, Throwable t, String format, Object... params) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).logf(level, t, format, params); } /** @@ -2608,9 +2810,10 @@ public static void logf(Logger.Level level, Throwable t, String format, Object.. * @param param1 the sole parameter */ public static void logf(Logger.Level level, Throwable t, String format, Object param1) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).logf(level, t, format, param1); } /** @@ -2623,9 +2826,10 @@ public static void logf(Logger.Level level, Throwable t, String format, Object p * @param param2 the second parameter */ public static void logf(Logger.Level level, Throwable t, String format, Object param1, Object param2) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).logf(level, t, format, param1, param2); } /** @@ -2639,9 +2843,10 @@ public static void logf(Logger.Level level, Throwable t, String format, Object p * @param param3 the third parameter */ public static void logf(Logger.Level level, Throwable t, String format, Object param1, Object param2, Object param3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).logf(level, t, format, param1, param2, param3); } /** @@ -2654,9 +2859,10 @@ public static void logf(Logger.Level level, Throwable t, String format, Object p * @param param1 the sole parameter */ public static void logf(String loggerFqcn, Logger.Level level, Throwable t, String format, Object param1) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).logf(loggerFqcn, level, t, format, param1); } /** @@ -2670,9 +2876,10 @@ public static void logf(String loggerFqcn, Logger.Level level, Throwable t, Stri * @param param2 the second parameter */ public static void logf(String loggerFqcn, Logger.Level level, Throwable t, String format, Object param1, Object param2) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).logf(loggerFqcn, level, t, format, param1, param2); } /** @@ -2688,9 +2895,10 @@ public static void logf(String loggerFqcn, Logger.Level level, Throwable t, Stri */ public static void logf(String loggerFqcn, Logger.Level level, Throwable t, String format, Object param1, Object param2, Object param3) { - if (always()) { + if (shouldFail) { throw fail(); } + Logger.getLogger(stackWalker.getCallerClass()).logf(loggerFqcn, level, t, format, param1, param2, param3); } /** @@ -2703,17 +2911,14 @@ public static void logf(String loggerFqcn, Logger.Level level, Throwable t, Stri * @param params the message parameters */ public static void logf(String loggerFqcn, Logger.Level level, Throwable t, String format, Object... params) { - if (always()) { + if (shouldFail) { throw fail(); } - } - - private static boolean always() { - return true; + Logger.getLogger(stackWalker.getCallerClass()).logf(loggerFqcn, level, t, format, params); } private static UnsupportedOperationException fail() { - return new UnsupportedOperationException("Using " + Log.class.getName() - + " is only possible with Quarkus bytecode transformation"); + return new UnsupportedOperationException( + "Using io.quarkus.logging.Log is only possible with Quarkus bytecode transformation"); } } diff --git a/core/runtime/src/test/java/io/quarkus/logging/GenerateLog.java b/core/runtime/src/test/java/io/quarkus/logging/GenerateLog.java index d8830d2d7a508..b108f58de3d38 100644 --- a/core/runtime/src/test/java/io/quarkus/logging/GenerateLog.java +++ b/core/runtime/src/test/java/io/quarkus/logging/GenerateLog.java @@ -8,46 +8,36 @@ import java.net.http.HttpResponse; import java.nio.charset.StandardCharsets; import java.time.Duration; +import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; +import java.util.stream.Collectors; import org.jboss.logging.BasicLogger; +import org.jboss.logging.Logger; + +import com.github.javaparser.StaticJavaParser; +import com.github.javaparser.ast.CompilationUnit; +import com.github.javaparser.ast.Modifier; +import com.github.javaparser.ast.NodeList; +import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; +import com.github.javaparser.ast.body.MethodDeclaration; +import com.github.javaparser.ast.body.Parameter; +import com.github.javaparser.ast.comments.LineComment; +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.expr.MethodCallExpr; +import com.github.javaparser.ast.nodeTypes.NodeWithSimpleName; +import com.github.javaparser.ast.stmt.BlockStmt; +import com.github.javaparser.ast.stmt.CatchClause; +import com.github.javaparser.ast.stmt.ReturnStmt; +import com.github.javaparser.ast.stmt.TryStmt; +import com.github.javaparser.ast.type.PrimitiveType; public class GenerateLog { - private static final String PACKAGE_AND_IMPORT = "" + - "package " + Log.class.getPackageName() + ";\n" + - "\n" + - "import org.jboss.logging.Logger;"; - private static final String CLASS_HEADER = "" + - "/**\n" + - " * Copy of {@link org.jboss.logging.BasicLogger}.\n" + - " * Invocations of all {@code static} methods of this class are, during build time, replaced by invocations\n" + - " * of the same methods on a generated instance of {@link Logger}.\n" + - " */\n" + - "public final class Log {\n" + - " // automatically generated by io.quarkus.logging.GenerateLog"; - // the conditions here are an attempt to stop IntelliJ flagging the Log methods as always throwing - private static final String VOID_METHOD_BODY = ") {\n" + - " if (always()) {\n" + - " throw fail();\n" + - " }\n" + - " }"; - private static final String BOOLEAN_METHOD_BODY = ") {\n" + - " if (always()) {\n" + - " throw fail();\n" + - " }\n" + - " return always();\n" + - " }"; - private static final String FAIL_METHOD = "" + - "\n" + - " private static boolean always() {\n" + - " return true;\n" + - " }\n" + - "\n" + - " private static UnsupportedOperationException fail() {\n" + - " return new UnsupportedOperationException(\"Using \" + Log.class.getName()\n" + - " + \" is only possible with Quarkus bytecode transformation\");\n" + - " }\n"; + private static final String CLASS_JAVADOC = "" + + "Copy of {@link org.jboss.logging.BasicLogger}.\n" + + "Invocations of all {@code static} methods of this class are, during build time, replaced by invocations\n" + + "of the same methods on a generated instance of {@link Logger}."; public static void main(String[] args) throws Exception { String source = BasicLogger.class.getProtectionDomain().getCodeSource().getLocation().getPath(); @@ -72,14 +62,81 @@ public static void main(String[] args) throws Exception { } } - private static void generateLogClass(String basicLogger) { - String quarkusLog = basicLogger - .replaceFirst("(?s).*?package org.jboss.logging;", PACKAGE_AND_IMPORT) - .replaceFirst("(?s)/\\*\\*.*?public interface BasicLogger \\{", CLASS_HEADER) - .replaceAll("void (.*?)\\);", "public static void $1" + VOID_METHOD_BODY) - .replaceAll("boolean (.*?)\\);", "public static boolean $1" + BOOLEAN_METHOD_BODY) - .replaceFirst("}\\s*$", FAIL_METHOD + "}\n"); + private static void generateLogClass(String templateSource) { + CompilationUnit templateUnit = StaticJavaParser.parse(templateSource); + ClassOrInterfaceDeclaration templateClass = (ClassOrInterfaceDeclaration) templateUnit.getTypes().get(0); + + CompilationUnit unit = new CompilationUnit(); + unit.setPackageDeclaration("io.quarkus.logging"); + unit.addImport(Logger.class); + unit.addOrphanComment(new LineComment(" automatically generated by io.quarkus.logging.GenerateLog")); + + ClassOrInterfaceDeclaration clazz = unit.addClass("Log", Modifier.Keyword.PUBLIC, Modifier.Keyword.FINAL) + .setJavadocComment(CLASS_JAVADOC); + + clazz.addFieldWithInitializer("StackWalker", "stackWalker", + StaticJavaParser.parseExpression("StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE)"), + Modifier.Keyword.PRIVATE, Modifier.Keyword.STATIC, Modifier.Keyword.FINAL); + + clazz.addFieldWithInitializer(PrimitiveType.booleanType(), "shouldFail", + StaticJavaParser.parseExpression("!isTest()"), + Modifier.Keyword.PRIVATE, Modifier.Keyword.STATIC, Modifier.Keyword.FINAL); + + { + MethodDeclaration method = clazz.addMethod("isTest"); + method.setPrivate(true); + method.setStatic(true); + method.setType(PrimitiveType.booleanType()); + BlockStmt body = new BlockStmt(); + + BlockStmt tryPart = new BlockStmt(); + tryPart.addStatement("Class.forName(\"org.junit.jupiter.api.Assertions\");"); + tryPart.addStatement("return true;"); + + BlockStmt catchPart = new BlockStmt(); + catchPart.addStatement("return false;"); + CatchClause catchClause = new CatchClause( + new Parameter(StaticJavaParser.parseType(ClassNotFoundException.class.getName()), "ignored"), + catchPart); + + body.addStatement(new TryStmt(tryPart, new NodeList<>(catchClause), null)); + method.setBody(body); + } + + for (MethodDeclaration methodTemplate : templateClass.getMethods()) { + MethodDeclaration method = clazz.addMethod(methodTemplate.getNameAsString()); + method.setJavadocComment(methodTemplate.getJavadoc().orElseThrow()); + method.setPublic(true); + method.setStatic(true); + method.setType(methodTemplate.getType()); + method.setParameters(methodTemplate.getParameters()); + BlockStmt body = new BlockStmt(); + body.addStatement("if (shouldFail) { throw fail(); }"); + Expression logger = StaticJavaParser + .parseExpression("Logger.getLogger(stackWalker.getCallerClass())"); + List forwardParams = methodTemplate.getParameters() + .stream() + .map(NodeWithSimpleName::getNameAsExpression) + .collect(Collectors.toList()); + MethodCallExpr forwardCall = new MethodCallExpr(logger, methodTemplate.getName().getIdentifier(), + new NodeList<>(forwardParams)); + if (methodTemplate.getType().isVoidType()) { + body.addStatement(forwardCall); + } else { + body.addStatement(new ReturnStmt(forwardCall)); + } + method.setBody(body); + } + + { + MethodDeclaration method = clazz.addMethod("fail", Modifier.Keyword.PRIVATE, Modifier.Keyword.STATIC); + method.setType(UnsupportedOperationException.class); + BlockStmt body = new BlockStmt(); + body.addStatement("return new UnsupportedOperationException(\"Using " + Log.class.getName() + + " is only possible with Quarkus bytecode transformation\");"); + method.setBody(body); + } - System.out.println(quarkusLog); + System.out.println(unit); } } diff --git a/core/runtime/src/test/java/io/quarkus/logging/LoggingApiCompletenessTest.java b/core/runtime/src/test/java/io/quarkus/logging/LoggingApiCompletenessTest.java index 49d8e52d32511..33673ab52f9c0 100644 --- a/core/runtime/src/test/java/io/quarkus/logging/LoggingApiCompletenessTest.java +++ b/core/runtime/src/test/java/io/quarkus/logging/LoggingApiCompletenessTest.java @@ -17,7 +17,7 @@ public class LoggingApiCompletenessTest { public void compareWithJbossLogging() { Method[] jbossLoggingMethods = BasicLogger.class.getDeclaredMethods(); Method[] quarkusLogMethods = Arrays.stream(Log.class.getDeclaredMethods()) - .filter(Predicate.not(LoggingApiCompletenessTest::isPrivateStaticFail)) + .filter(Predicate.not(LoggingApiCompletenessTest::isPrivateStaticAdditionalMethod)) .toArray(Method[]::new); List mismatches = new ArrayList<>(); @@ -59,10 +59,10 @@ public void compareWithJbossLogging() { } } - private static boolean isPrivateStaticFail(Method method) { + private static boolean isPrivateStaticAdditionalMethod(Method method) { return Modifier.isPrivate(method.getModifiers()) && Modifier.isStatic(method.getModifiers()) - && ("fail".equals(method.getName()) || "always".equals(method.getName())); + && ("fail".equals(method.getName()) || "isTest".equals(method.getName())); } private static boolean areEquivalent(Method jbossLoggingMethod, Method quarkusLogMethod) { diff --git a/integration-tests/logging-panache/src/test/java/io/quarkus/logging/GenerateAllLogUsages.java b/integration-tests/logging-panache/src/test/java/io/quarkus/logging/GenerateAllLogUsages.java index 4341ee3c653da..46707de11363c 100644 --- a/integration-tests/logging-panache/src/test/java/io/quarkus/logging/GenerateAllLogUsages.java +++ b/integration-tests/logging-panache/src/test/java/io/quarkus/logging/GenerateAllLogUsages.java @@ -17,7 +17,8 @@ public static void main(String[] args) { println(" public void testLogging() {"); Arrays.stream(Log.class.getDeclaredMethods()) .filter(method -> Modifier.isPublic(method.getModifiers())) - .sorted(Comparator.comparing(Method::getName).thenComparingInt(Method::getParameterCount)) + .sorted(Comparator.comparing(Method::getName).thenComparingInt(Method::getParameterCount) + .thenComparing(Method::toString)) .forEach(method -> { Parameter[] parameters = method.getParameters(); String[] arguments = new String[method.getParameterCount()]; diff --git a/integration-tests/logging-panache/src/test/java/io/quarkus/logging/GeneratedBean.java b/integration-tests/logging-panache/src/test/java/io/quarkus/logging/GeneratedBean.java index 7dea885e5c4c9..a54bae652ad3c 100644 --- a/integration-tests/logging-panache/src/test/java/io/quarkus/logging/GeneratedBean.java +++ b/integration-tests/logging-panache/src/test/java/io/quarkus/logging/GeneratedBean.java @@ -7,43 +7,43 @@ public void testLogging() { Log.debug("foobar", new NoStackTraceTestException()); Log.debug("io.quarkus.logging.GeneratedBean", "foobar", new NoStackTraceTestException()); Log.debug("io.quarkus.logging.GeneratedBean", "foobar", new Object[] {}, new NoStackTraceTestException()); - Log.debugf("foobar", new Object[] {}); - Log.debugf("foobar", new Object()); Log.debugf("foobar", 13); + Log.debugf("foobar", new Object()); + Log.debugf("foobar", new Object[] {}); Log.debugf("foobar", 42L); - Log.debugf("foobar", 13, new Object()); Log.debugf("foobar", 13, 13); - Log.debugf(new NoStackTraceTestException(), "foobar", 13); - Log.debugf(new NoStackTraceTestException(), "foobar", new Object[] {}); + Log.debugf("foobar", 13, new Object()); Log.debugf("foobar", new Object(), new Object()); - Log.debugf(new NoStackTraceTestException(), "foobar", new Object()); - Log.debugf(new NoStackTraceTestException(), "foobar", 42L); Log.debugf("foobar", 42L, new Object()); Log.debugf("foobar", 42L, 42L); - Log.debugf(new NoStackTraceTestException(), "foobar", 42L, new Object()); - Log.debugf(new NoStackTraceTestException(), "foobar", 42L, 42L); - Log.debugf("foobar", 13, 13, new Object()); + Log.debugf(new NoStackTraceTestException(), "foobar", 13); + Log.debugf(new NoStackTraceTestException(), "foobar", new Object()); + Log.debugf(new NoStackTraceTestException(), "foobar", new Object[] {}); + Log.debugf(new NoStackTraceTestException(), "foobar", 42L); Log.debugf("foobar", 13, 13, 13); - Log.debugf(new NoStackTraceTestException(), "foobar", 13, new Object()); - Log.debugf(new NoStackTraceTestException(), "foobar", 13, 13); + Log.debugf("foobar", 13, 13, new Object()); Log.debugf("foobar", 13, new Object(), new Object()); Log.debugf("foobar", new Object(), new Object(), new Object()); - Log.debugf(new NoStackTraceTestException(), "foobar", new Object(), new Object()); - Log.debugf("foobar", 42L, 42L, 42L); - Log.debugf("foobar", 42L, 42L, new Object()); Log.debugf("foobar", 42L, new Object(), new Object()); - Log.debugf(new NoStackTraceTestException(), "foobar", 42L, 42L, 42L); - Log.debugf(new NoStackTraceTestException(), "foobar", 42L, 42L, new Object()); - Log.debugf(new NoStackTraceTestException(), "foobar", 42L, new Object(), new Object()); - Log.debugf(new NoStackTraceTestException(), "foobar", new Object(), new Object(), new Object()); - Log.debugf(new NoStackTraceTestException(), "foobar", 13, new Object(), new Object()); - Log.debugf(new NoStackTraceTestException(), "foobar", 13, 13, new Object()); + Log.debugf("foobar", 42L, 42L, new Object()); + Log.debugf("foobar", 42L, 42L, 42L); + Log.debugf(new NoStackTraceTestException(), "foobar", 13, 13); + Log.debugf(new NoStackTraceTestException(), "foobar", 13, new Object()); + Log.debugf(new NoStackTraceTestException(), "foobar", new Object(), new Object()); + Log.debugf(new NoStackTraceTestException(), "foobar", 42L, new Object()); + Log.debugf(new NoStackTraceTestException(), "foobar", 42L, 42L); Log.debugf(new NoStackTraceTestException(), "foobar", 13, 13, 13); - Log.debugv("foobar", new Object[] {}); + Log.debugf(new NoStackTraceTestException(), "foobar", 13, 13, new Object()); + Log.debugf(new NoStackTraceTestException(), "foobar", 13, new Object(), new Object()); + Log.debugf(new NoStackTraceTestException(), "foobar", new Object(), new Object(), new Object()); + Log.debugf(new NoStackTraceTestException(), "foobar", 42L, new Object(), new Object()); + Log.debugf(new NoStackTraceTestException(), "foobar", 42L, 42L, new Object()); + Log.debugf(new NoStackTraceTestException(), "foobar", 42L, 42L, 42L); Log.debugv("foobar", new Object()); - Log.debugv(new NoStackTraceTestException(), "foobar", new Object[] {}); + Log.debugv("foobar", new Object[] {}); Log.debugv("foobar", new Object(), new Object()); Log.debugv(new NoStackTraceTestException(), "foobar", new Object()); + Log.debugv(new NoStackTraceTestException(), "foobar", new Object[] {}); Log.debugv("foobar", new Object(), new Object(), new Object()); Log.debugv(new NoStackTraceTestException(), "foobar", new Object(), new Object()); Log.debugv(new NoStackTraceTestException(), "foobar", new Object(), new Object(), new Object()); @@ -51,21 +51,21 @@ public void testLogging() { Log.error("foobar", new NoStackTraceTestException()); Log.error("io.quarkus.logging.GeneratedBean", "foobar", new NoStackTraceTestException()); Log.error("io.quarkus.logging.GeneratedBean", "foobar", new Object[] {}, new NoStackTraceTestException()); - Log.errorf("foobar", new Object[] {}); Log.errorf("foobar", new Object()); + Log.errorf("foobar", new Object[] {}); Log.errorf("foobar", new Object(), new Object()); Log.errorf(new NoStackTraceTestException(), "foobar", new Object()); Log.errorf(new NoStackTraceTestException(), "foobar", new Object[] {}); - Log.errorf(new NoStackTraceTestException(), "foobar", new Object(), new Object()); Log.errorf("foobar", new Object(), new Object(), new Object()); + Log.errorf(new NoStackTraceTestException(), "foobar", new Object(), new Object()); Log.errorf(new NoStackTraceTestException(), "foobar", new Object(), new Object(), new Object()); - Log.errorv("foobar", new Object[] {}); Log.errorv("foobar", new Object()); - Log.errorv(new NoStackTraceTestException(), "foobar", new Object()); + Log.errorv("foobar", new Object[] {}); Log.errorv("foobar", new Object(), new Object()); + Log.errorv(new NoStackTraceTestException(), "foobar", new Object()); Log.errorv(new NoStackTraceTestException(), "foobar", new Object[] {}); - Log.errorv(new NoStackTraceTestException(), "foobar", new Object(), new Object()); Log.errorv("foobar", new Object(), new Object(), new Object()); + Log.errorv(new NoStackTraceTestException(), "foobar", new Object(), new Object()); Log.errorv(new NoStackTraceTestException(), "foobar", new Object(), new Object(), new Object()); Log.fatal("foobar"); Log.fatal("foobar", new NoStackTraceTestException()); @@ -73,37 +73,37 @@ public void testLogging() { Log.fatal("io.quarkus.logging.GeneratedBean", "foobar", new Object[] {}, new NoStackTraceTestException()); Log.fatalf("foobar", new Object()); Log.fatalf("foobar", new Object[] {}); - Log.fatalf(new NoStackTraceTestException(), "foobar", new Object[] {}); - Log.fatalf(new NoStackTraceTestException(), "foobar", new Object()); Log.fatalf("foobar", new Object(), new Object()); + Log.fatalf(new NoStackTraceTestException(), "foobar", new Object()); + Log.fatalf(new NoStackTraceTestException(), "foobar", new Object[] {}); Log.fatalf("foobar", new Object(), new Object(), new Object()); Log.fatalf(new NoStackTraceTestException(), "foobar", new Object(), new Object()); Log.fatalf(new NoStackTraceTestException(), "foobar", new Object(), new Object(), new Object()); - Log.fatalv("foobar", new Object[] {}); Log.fatalv("foobar", new Object()); - Log.fatalv(new NoStackTraceTestException(), "foobar", new Object[] {}); - Log.fatalv(new NoStackTraceTestException(), "foobar", new Object()); + Log.fatalv("foobar", new Object[] {}); Log.fatalv("foobar", new Object(), new Object()); - Log.fatalv(new NoStackTraceTestException(), "foobar", new Object(), new Object()); + Log.fatalv(new NoStackTraceTestException(), "foobar", new Object()); + Log.fatalv(new NoStackTraceTestException(), "foobar", new Object[] {}); Log.fatalv("foobar", new Object(), new Object(), new Object()); + Log.fatalv(new NoStackTraceTestException(), "foobar", new Object(), new Object()); Log.fatalv(new NoStackTraceTestException(), "foobar", new Object(), new Object(), new Object()); Log.info("foobar"); Log.info("foobar", new NoStackTraceTestException()); Log.info("io.quarkus.logging.GeneratedBean", "foobar", new NoStackTraceTestException()); Log.info("io.quarkus.logging.GeneratedBean", "foobar", new Object[] {}, new NoStackTraceTestException()); - Log.infof("foobar", new Object[] {}); Log.infof("foobar", new Object()); - Log.infof(new NoStackTraceTestException(), "foobar", new Object[] {}); - Log.infof(new NoStackTraceTestException(), "foobar", new Object()); + Log.infof("foobar", new Object[] {}); Log.infof("foobar", new Object(), new Object()); - Log.infof(new NoStackTraceTestException(), "foobar", new Object(), new Object()); + Log.infof(new NoStackTraceTestException(), "foobar", new Object()); + Log.infof(new NoStackTraceTestException(), "foobar", new Object[] {}); Log.infof("foobar", new Object(), new Object(), new Object()); + Log.infof(new NoStackTraceTestException(), "foobar", new Object(), new Object()); Log.infof(new NoStackTraceTestException(), "foobar", new Object(), new Object(), new Object()); - Log.infov("foobar", new Object[] {}); Log.infov("foobar", new Object()); - Log.infov(new NoStackTraceTestException(), "foobar", new Object[] {}); - Log.infov(new NoStackTraceTestException(), "foobar", new Object()); + Log.infov("foobar", new Object[] {}); Log.infov("foobar", new Object(), new Object()); + Log.infov(new NoStackTraceTestException(), "foobar", new Object()); + Log.infov(new NoStackTraceTestException(), "foobar", new Object[] {}); Log.infov("foobar", new Object(), new Object(), new Object()); Log.infov(new NoStackTraceTestException(), "foobar", new Object(), new Object()); Log.infov(new NoStackTraceTestException(), "foobar", new Object(), new Object(), new Object()); @@ -120,13 +120,13 @@ public void testLogging() { Log.logf(org.jboss.logging.Logger.Level.INFO, "foobar", new Object()); Log.logf(org.jboss.logging.Logger.Level.INFO, "foobar", new Object[] {}); Log.logf(org.jboss.logging.Logger.Level.INFO, "foobar", new Object(), new Object()); - Log.logf(org.jboss.logging.Logger.Level.INFO, new NoStackTraceTestException(), "foobar", new Object[] {}); Log.logf(org.jboss.logging.Logger.Level.INFO, new NoStackTraceTestException(), "foobar", new Object()); - Log.logf(org.jboss.logging.Logger.Level.INFO, "foobar", new Object(), new Object(), new Object()); + Log.logf(org.jboss.logging.Logger.Level.INFO, new NoStackTraceTestException(), "foobar", new Object[] {}); Log.logf("io.quarkus.logging.GeneratedBean", org.jboss.logging.Logger.Level.INFO, new NoStackTraceTestException(), "foobar", new Object()); Log.logf("io.quarkus.logging.GeneratedBean", org.jboss.logging.Logger.Level.INFO, new NoStackTraceTestException(), "foobar", new Object[] {}); + Log.logf(org.jboss.logging.Logger.Level.INFO, "foobar", new Object(), new Object(), new Object()); Log.logf(org.jboss.logging.Logger.Level.INFO, new NoStackTraceTestException(), "foobar", new Object(), new Object()); Log.logf("io.quarkus.logging.GeneratedBean", org.jboss.logging.Logger.Level.INFO, new NoStackTraceTestException(), "foobar", new Object(), new Object()); @@ -139,81 +139,81 @@ public void testLogging() { Log.logv(org.jboss.logging.Logger.Level.INFO, "foobar", new Object(), new Object()); Log.logv(org.jboss.logging.Logger.Level.INFO, new NoStackTraceTestException(), "foobar", new Object()); Log.logv(org.jboss.logging.Logger.Level.INFO, new NoStackTraceTestException(), "foobar", new Object[] {}); - Log.logv(org.jboss.logging.Logger.Level.INFO, "foobar", new Object(), new Object(), new Object()); - Log.logv("io.quarkus.logging.GeneratedBean", org.jboss.logging.Logger.Level.INFO, new NoStackTraceTestException(), - "foobar", new Object[] {}); Log.logv("io.quarkus.logging.GeneratedBean", org.jboss.logging.Logger.Level.INFO, new NoStackTraceTestException(), "foobar", new Object()); + Log.logv("io.quarkus.logging.GeneratedBean", org.jboss.logging.Logger.Level.INFO, new NoStackTraceTestException(), + "foobar", new Object[] {}); + Log.logv(org.jboss.logging.Logger.Level.INFO, "foobar", new Object(), new Object(), new Object()); Log.logv(org.jboss.logging.Logger.Level.INFO, new NoStackTraceTestException(), "foobar", new Object(), new Object()); - Log.logv(org.jboss.logging.Logger.Level.INFO, new NoStackTraceTestException(), "foobar", new Object(), new Object(), - new Object()); Log.logv("io.quarkus.logging.GeneratedBean", org.jboss.logging.Logger.Level.INFO, new NoStackTraceTestException(), "foobar", new Object(), new Object()); + Log.logv(org.jboss.logging.Logger.Level.INFO, new NoStackTraceTestException(), "foobar", new Object(), new Object(), + new Object()); Log.logv("io.quarkus.logging.GeneratedBean", org.jboss.logging.Logger.Level.INFO, new NoStackTraceTestException(), "foobar", new Object(), new Object(), new Object()); Log.trace("foobar"); Log.trace("foobar", new NoStackTraceTestException()); Log.trace("io.quarkus.logging.GeneratedBean", "foobar", new NoStackTraceTestException()); Log.trace("io.quarkus.logging.GeneratedBean", "foobar", new Object[] {}, new NoStackTraceTestException()); - Log.tracef("foobar", new Object[] {}); - Log.tracef("foobar", new Object()); Log.tracef("foobar", 13); + Log.tracef("foobar", new Object()); + Log.tracef("foobar", new Object[] {}); Log.tracef("foobar", 42L); - Log.tracef(new NoStackTraceTestException(), "foobar", 42L); - Log.tracef("foobar", new Object(), new Object()); - Log.tracef(new NoStackTraceTestException(), "foobar", new Object[] {}); - Log.tracef(new NoStackTraceTestException(), "foobar", new Object()); - Log.tracef("foobar", 13, new Object()); - Log.tracef(new NoStackTraceTestException(), "foobar", 13); Log.tracef("foobar", 13, 13); - Log.tracef("foobar", 42L, 42L); + Log.tracef("foobar", 13, new Object()); + Log.tracef("foobar", new Object(), new Object()); Log.tracef("foobar", 42L, new Object()); - Log.tracef(new NoStackTraceTestException(), "foobar", 42L, new Object()); - Log.tracef(new NoStackTraceTestException(), "foobar", 42L, 42L); - Log.tracef("foobar", 42L, new Object(), new Object()); - Log.tracef("foobar", new Object(), new Object(), new Object()); - Log.tracef(new NoStackTraceTestException(), "foobar", new Object(), new Object()); - Log.tracef("foobar", 13, new Object(), new Object()); - Log.tracef(new NoStackTraceTestException(), "foobar", 13, 13); + Log.tracef("foobar", 42L, 42L); + Log.tracef(new NoStackTraceTestException(), "foobar", 13); + Log.tracef(new NoStackTraceTestException(), "foobar", new Object()); + Log.tracef(new NoStackTraceTestException(), "foobar", new Object[] {}); + Log.tracef(new NoStackTraceTestException(), "foobar", 42L); Log.tracef("foobar", 13, 13, 13); Log.tracef("foobar", 13, 13, new Object()); - Log.tracef("foobar", 42L, 42L, 42L); + Log.tracef("foobar", 13, new Object(), new Object()); + Log.tracef("foobar", new Object(), new Object(), new Object()); + Log.tracef("foobar", 42L, new Object(), new Object()); Log.tracef("foobar", 42L, 42L, new Object()); + Log.tracef("foobar", 42L, 42L, 42L); + Log.tracef(new NoStackTraceTestException(), "foobar", 13, 13); Log.tracef(new NoStackTraceTestException(), "foobar", 13, new Object()); - Log.tracef(new NoStackTraceTestException(), "foobar", 42L, 42L, 42L); - Log.tracef(new NoStackTraceTestException(), "foobar", 42L, 42L, new Object()); - Log.tracef(new NoStackTraceTestException(), "foobar", 42L, new Object(), new Object()); - Log.tracef(new NoStackTraceTestException(), "foobar", new Object(), new Object(), new Object()); - Log.tracef(new NoStackTraceTestException(), "foobar", 13, new Object(), new Object()); + Log.tracef(new NoStackTraceTestException(), "foobar", new Object(), new Object()); + Log.tracef(new NoStackTraceTestException(), "foobar", 42L, new Object()); + Log.tracef(new NoStackTraceTestException(), "foobar", 42L, 42L); Log.tracef(new NoStackTraceTestException(), "foobar", 13, 13, 13); Log.tracef(new NoStackTraceTestException(), "foobar", 13, 13, new Object()); + Log.tracef(new NoStackTraceTestException(), "foobar", 13, new Object(), new Object()); + Log.tracef(new NoStackTraceTestException(), "foobar", new Object(), new Object(), new Object()); + Log.tracef(new NoStackTraceTestException(), "foobar", 42L, new Object(), new Object()); + Log.tracef(new NoStackTraceTestException(), "foobar", 42L, 42L, new Object()); + Log.tracef(new NoStackTraceTestException(), "foobar", 42L, 42L, 42L); Log.tracev("foobar", new Object()); Log.tracev("foobar", new Object[] {}); Log.tracev("foobar", new Object(), new Object()); Log.tracev(new NoStackTraceTestException(), "foobar", new Object()); Log.tracev(new NoStackTraceTestException(), "foobar", new Object[] {}); - Log.tracev(new NoStackTraceTestException(), "foobar", new Object(), new Object()); Log.tracev("foobar", new Object(), new Object(), new Object()); + Log.tracev(new NoStackTraceTestException(), "foobar", new Object(), new Object()); Log.tracev(new NoStackTraceTestException(), "foobar", new Object(), new Object(), new Object()); Log.warn("foobar"); Log.warn("foobar", new NoStackTraceTestException()); Log.warn("io.quarkus.logging.GeneratedBean", "foobar", new NoStackTraceTestException()); Log.warn("io.quarkus.logging.GeneratedBean", "foobar", new Object[] {}, new NoStackTraceTestException()); - Log.warnf("foobar", new Object[] {}); Log.warnf("foobar", new Object()); - Log.warnf(new NoStackTraceTestException(), "foobar", new Object()); + Log.warnf("foobar", new Object[] {}); Log.warnf("foobar", new Object(), new Object()); + Log.warnf(new NoStackTraceTestException(), "foobar", new Object()); Log.warnf(new NoStackTraceTestException(), "foobar", new Object[] {}); - Log.warnf(new NoStackTraceTestException(), "foobar", new Object(), new Object()); Log.warnf("foobar", new Object(), new Object(), new Object()); + Log.warnf(new NoStackTraceTestException(), "foobar", new Object(), new Object()); Log.warnf(new NoStackTraceTestException(), "foobar", new Object(), new Object(), new Object()); - Log.warnv("foobar", new Object[] {}); Log.warnv("foobar", new Object()); + Log.warnv("foobar", new Object[] {}); Log.warnv("foobar", new Object(), new Object()); - Log.warnv(new NoStackTraceTestException(), "foobar", new Object[] {}); Log.warnv(new NoStackTraceTestException(), "foobar", new Object()); - Log.warnv(new NoStackTraceTestException(), "foobar", new Object(), new Object()); + Log.warnv(new NoStackTraceTestException(), "foobar", new Object[] {}); Log.warnv("foobar", new Object(), new Object(), new Object()); + Log.warnv(new NoStackTraceTestException(), "foobar", new Object(), new Object()); Log.warnv(new NoStackTraceTestException(), "foobar", new Object(), new Object(), new Object()); } } diff --git a/integration-tests/logging-panache/src/test/java/io/quarkus/logging/LoggingWithoutQuarkusTest.java b/integration-tests/logging-panache/src/test/java/io/quarkus/logging/LoggingWithoutQuarkusTest.java new file mode 100644 index 0000000000000..6083bf56c4d78 --- /dev/null +++ b/integration-tests/logging-panache/src/test/java/io/quarkus/logging/LoggingWithoutQuarkusTest.java @@ -0,0 +1,10 @@ +package io.quarkus.logging; + +import org.junit.jupiter.api.Test; + +public class LoggingWithoutQuarkusTest { + @Test + public void test() { + Log.error("This should not fail, we're in a test"); + } +}