TaggedLogger { public void debug(final Object message) { if (minimumLevelCoversDebug) { provider.log(STACKTRACE_DEPTH, tag, Level.DEBUG, null, null, message, (Object[]) null); } } TaggedLogger(final String tag); boolean isTraceEnabled(); void trace(final Object message); void trace(final Supplier<?> message); void trace(final String message, final Object... arguments); void trace(final String message, final Supplier<?>... arguments); void trace(final Throwable exception); void trace(final Throwable exception, final String message); void trace(final Throwable exception, final Supplier<String> message); void trace(final Throwable exception, final String message, final Object... arguments); void trace(final Throwable exception, final String message, final Supplier<?>... arguments); boolean isDebugEnabled(); void debug(final Object message); void debug(final Supplier<?> message); void debug(final String message, final Object... arguments); void debug(final String message, final Supplier<?>... arguments); void debug(final Throwable exception); void debug(final Throwable exception, final String message); void debug(final Throwable exception, final Supplier<String> message); void debug(final Throwable exception, final String message, final Object... arguments); void debug(final Throwable exception, final String message, final Supplier<?>... arguments); boolean isInfoEnabled(); void info(final Object message); void info(final Supplier<?> message); void info(final String message, final Object... arguments); void info(final String message, final Supplier<?>... arguments); void info(final Throwable exception); void info(final Throwable exception, final String message); void info(final Throwable exception, final Supplier<String> message); void info(final Throwable exception, final String message, final Object... arguments); void info(final Throwable exception, final String message, final Supplier<?>... arguments); boolean isWarnEnabled(); void warn(final Object message); void warn(final Supplier<?> message); void warn(final String message, final Object... arguments); void warn(final String message, final Supplier<?>... arguments); void warn(final Throwable exception); void warn(final Throwable exception, final String message); void warn(final Throwable exception, final Supplier<String> message); void warn(final Throwable exception, final String message, final Object... arguments); void warn(final Throwable exception, final String message, final Supplier<?>... arguments); boolean isErrorEnabled(); void error(final Object message); void error(final Supplier<?> message); void error(final String message, final Object... arguments); void error(final String message, final Supplier<?>... arguments); void error(final Throwable exception); void error(final Throwable exception, final String message); void error(final Throwable exception, final Supplier<String> message); void error(final Throwable exception, final String message, final Object... arguments); void error(final Throwable exception, final String message, final Supplier<?>... arguments);  }
@Test public void debugObject() { logger.debug("Hello World!"); if (debugEnabled) { verify(loggingProvider).log(eq(2), eq(TAG), eq(Level.DEBUG), isNull(), isNull(), eq("Hello World!"), isNull()); } else { verify(loggingProvider, never()).log(anyInt(), anyString(), any(), any(), any(), any(), any()); } }
@Test public void debugLazyMessage() { Supplier<String> supplier = mockSupplier("Hello World!"); logger.debug(supplier); verify(supplier, never()).get(); if (debugEnabled) { verify(loggingProvider).log(eq(2), eq(TAG), eq(Level.DEBUG), isNull(), isNull(), same(supplier), isNull()); } else { verify(loggingProvider, never()).log(anyInt(), anyString(), any(), any(), any(), any(), any()); } }
@Test public void debugMessageAndArguments() { logger.debug("Hello {}!", "World"); if (debugEnabled) { verify(loggingProvider).log(eq(2), eq(TAG), eq(Level.DEBUG), isNull(), any(AdvancedMessageFormatter.class), eq("Hello {}!"), eq("World")); } else { verify(loggingProvider, never()).log(anyInt(), anyString(), any(), any(), any(), any(), any()); } }
@Test public void debugMessageAndLazyArguments() { Supplier<Integer> supplier = mockSupplier(42); logger.debug("The number is {}", supplier); verify(supplier, never()).get(); if (debugEnabled) { verify(loggingProvider).log(eq(2), eq(TAG), eq(Level.DEBUG), isNull(), any(AdvancedMessageFormatter.class), eq("The number is {}"), same(supplier)); } else { verify(loggingProvider, never()).log(anyInt(), anyString(), any(), any(), any(), any(), any()); } }
@Test public void debugException() { Exception exception = new NullPointerException(); logger.debug(exception); if (debugEnabled) { verify(loggingProvider).log(eq(2), eq(TAG), eq(Level.DEBUG), same(exception), isNull(), isNull(), isNull()); } else { verify(loggingProvider, never()).log(anyInt(), anyString(), any(), any(), any(), any(), any()); } }
@Test public void debugExceptionWithMessage() { Exception exception = new NullPointerException(); logger.debug(exception, "Hello World!"); if (debugEnabled) { verify(loggingProvider).log(eq(2), eq(TAG), eq(Level.DEBUG), same(exception), isNull(), eq("Hello World!"), isNull()); } else { verify(loggingProvider, never()).log(anyInt(), anyString(), any(), any(), any(), any(), any()); } }
@Test public void debugExceptionWithLazyMessage() { Exception exception = new NullPointerException(); Supplier<String> supplier = mockSupplier("Hello World!"); logger.debug(exception, supplier); verify(supplier, never()).get(); if (debugEnabled) { verify(loggingProvider).log(eq(2), eq(TAG), eq(Level.DEBUG), same(exception), isNull(), same(supplier), isNull()); } else { verify(loggingProvider, never()).log(anyInt(), anyString(), any(), any(), any(), any(), any()); } }
@Test public void debugExceptionWithMessageAndArguments() { Exception exception = new NullPointerException(); logger.debug(exception, "Hello {}!", "World"); if (debugEnabled) { verify(loggingProvider).log(eq(2), eq(TAG), eq(Level.DEBUG), same(exception), any(AdvancedMessageFormatter.class), eq("Hello {}!"), eq("World")); } else { verify(loggingProvider, never()).log(anyInt(), anyString(), any(), any(), any(), any(), any()); } }
@Test public void debugExceptionWithMessageAndLazyArguments() { Exception exception = new NullPointerException(); Supplier<Integer> supplier = mockSupplier(42); logger.debug(exception, "The number is {}", supplier); verify(supplier, never()).get(); if (debugEnabled) { verify(loggingProvider).log(eq(2), eq(TAG), eq(Level.DEBUG), same(exception), any(AdvancedMessageFormatter.class), eq("The number is {}"), same(supplier)); } else { verify(loggingProvider, never()).log(anyInt(), anyString(), any(), any(), any(), any(), any()); } }