TaggedLogger { public void trace(final Object message) { if (minimumLevelCoversTrace) { provider.log(STACKTRACE_DEPTH, tag, Level.TRACE, 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 traceObject() { logger.trace("Hello World!"); if (traceEnabled) { verify(loggingProvider).log(eq(2), eq(TAG), eq(Level.TRACE), isNull(), isNull(), eq("Hello World!"), isNull()); } else { verify(loggingProvider, never()).log(anyInt(), anyString(), any(), any(), any(), any(), any()); } }
@Test public void traceLazyMessage() { Supplier<String> supplier = mockSupplier("Hello World!"); logger.trace(supplier); verify(supplier, never()).get(); if (traceEnabled) { verify(loggingProvider).log(eq(2), eq(TAG), eq(Level.TRACE), isNull(), isNull(), same(supplier), isNull()); } else { verify(loggingProvider, never()).log(anyInt(), anyString(), any(), any(), any(), any(), any()); } }
@Test public void traceMessageAndArguments() { logger.trace("Hello {}!", "World"); if (traceEnabled) { verify(loggingProvider).log(eq(2), eq(TAG), eq(Level.TRACE), isNull(), any(AdvancedMessageFormatter.class), eq("Hello {}!"), eq("World")); } else { verify(loggingProvider, never()).log(anyInt(), anyString(), any(), any(), any(), any(), any()); } }
@Test public void traceMessageAndLazyArguments() { Supplier<Integer> supplier = mockSupplier(42); logger.trace("The number is {}", supplier); verify(supplier, never()).get(); if (traceEnabled) { verify(loggingProvider).log(eq(2), eq(TAG), eq(Level.TRACE), 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 traceException() { Exception exception = new NullPointerException(); logger.trace(exception); if (traceEnabled) { verify(loggingProvider).log(eq(2), eq(TAG), eq(Level.TRACE), same(exception), isNull(), isNull(), isNull()); } else { verify(loggingProvider, never()).log(anyInt(), anyString(), any(), any(), any(), any(), any()); } }
@Test public void traceExceptionWithMessage() { Exception exception = new NullPointerException(); logger.trace(exception, "Hello World!"); if (traceEnabled) { verify(loggingProvider).log(eq(2), eq(TAG), eq(Level.TRACE), same(exception), isNull(), eq("Hello World!"), isNull()); } else { verify(loggingProvider, never()).log(anyInt(), anyString(), any(), any(), any(), any(), any()); } }
@Test public void traceExceptionWithLazyMessage() { Exception exception = new NullPointerException(); Supplier<String> supplier = mockSupplier("Hello World!"); logger.trace(exception, supplier); verify(supplier, never()).get(); if (traceEnabled) { verify(loggingProvider).log(eq(2), eq(TAG), eq(Level.TRACE), same(exception), isNull(), same(supplier), isNull()); } else { verify(loggingProvider, never()).log(anyInt(), anyString(), any(), any(), any(), any(), any()); } }
@Test public void traceExceptionWithMessageAndArguments() { Exception exception = new NullPointerException(); logger.trace(exception, "Hello {}!", "World"); if (traceEnabled) { verify(loggingProvider).log(eq(2), eq(TAG), eq(Level.TRACE), same(exception), any(AdvancedMessageFormatter.class), eq("Hello {}!"), eq("World")); } else { verify(loggingProvider, never()).log(anyInt(), anyString(), any(), any(), any(), any(), any()); } }
@Test public void traceExceptionWithMessageAndLazyArguments() { Exception exception = new NullPointerException(); Supplier<Integer> supplier = mockSupplier(42); logger.trace(exception, "The number is {}", supplier); verify(supplier, never()).get(); if (traceEnabled) { verify(loggingProvider).log(eq(2), eq(TAG), eq(Level.TRACE), same(exception), any(AdvancedMessageFormatter.class), eq("The number is {}"), same(supplier)); } else { verify(loggingProvider, never()).log(anyInt(), anyString(), any(), any(), any(), any(), any()); } }