Add a bit of documentation
This commit is contained in:
parent
3eeca4a8fd
commit
81de6cca32
|
@ -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
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Reference in New Issue