diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/LogUtil.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/LogUtil.java index e68a2b0ef9a..2cb5f06943d 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/LogUtil.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/LogUtil.java @@ -1,7 +1,15 @@ package ca.uhn.fhir.util; import org.slf4j.Logger; +import org.slf4j.event.Level; +/** + * Utility to fill a glaring gap in SLF4j's API - The fact that you can't + * specify a log level at runtime. + * + * See here for a discussion: + * https://jira.qos.ch/browse/SLF4J-124 + */ public class LogUtil { public static void log(Logger theLogger, Level theLevel, String theMessage, Object... theArgs) { @@ -24,8 +32,4 @@ public class LogUtil { } } - public enum Level { - TRACE, DEBUG, INFO, WARN, ERROR - } - } diff --git a/hapi-fhir-base/src/test/java/ca/uhn/fhir/util/LogUtilTest.java b/hapi-fhir-base/src/test/java/ca/uhn/fhir/util/LogUtilTest.java index 28d345fc0af..755d09d9010 100644 --- a/hapi-fhir-base/src/test/java/ca/uhn/fhir/util/LogUtilTest.java +++ b/hapi-fhir-base/src/test/java/ca/uhn/fhir/util/LogUtilTest.java @@ -2,6 +2,7 @@ package ca.uhn.fhir.util; import org.junit.Test; import org.slf4j.Logger; +import org.slf4j.event.Level; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.*; @@ -11,11 +12,11 @@ public class LogUtilTest { @Test public void testLevels() { Logger log = mock(Logger.class); - LogUtil.log(log, LogUtil.Level.TRACE, "HELLO"); - LogUtil.log(log, LogUtil.Level.DEBUG, "HELLO"); - LogUtil.log(log, LogUtil.Level.INFO, "HELLO"); - LogUtil.log(log, LogUtil.Level.WARN, "HELLO"); - LogUtil.log(log, LogUtil.Level.ERROR, "HELLO"); + LogUtil.log(log, Level.TRACE, "HELLO"); + LogUtil.log(log, Level.DEBUG, "HELLO"); + LogUtil.log(log, Level.INFO, "HELLO"); + LogUtil.log(log, Level.WARN, "HELLO"); + LogUtil.log(log, Level.ERROR, "HELLO"); verify(log, times(1)).trace(anyString(),any(Object[].class)); verify(log, times(1)).debug(anyString(),any(Object[].class));