@Test public void doNotWriteWarnLogIfDisabled() throws Exception { when(logger.isWarnEnabled()).thenReturn(false); when(ctx.level()).thenReturn(LogLevel.WARN); output.write(ctx); Mockito.verify(logger, never()).warn(anyString()); Mockito.verify(logger).isWarnEnabled(); }
@Override public void write(final LogContext log) { final LogLevel level = log.level(); final Throwable throwable = log.throwable(); final ArrayList<Throwable> suppressedThrowables = log.suppressedThrowables(); if (throwable != null && suppressedThrowables != null) { for (Throwable t : suppressedThrowables) { throwable.addSuppressed(t); } } switch (level != null ? level : LogLevel.INFO) { case DEBUG: if (logger.isDebugEnabled()) { final String message = format(log); if (throwable != null) { logger.debug(message, throwable); } else { logger.debug(message); } } break; case INFO: if (logger.isInfoEnabled()) { final String message = format(log); if (throwable != null) { logger.info(message, throwable); } else { logger.info(message); } } break; case WARN: if (logger.isWarnEnabled()) { final String message = format(log); if (throwable != null) { logger.warn(message, throwable); } else { logger.warn(message); } } break; case ERROR: default: if (logger.isErrorEnabled()) { final String message = format(log); if (throwable != null) { logger.error(message, throwable); } else { logger.error(message); } } } }
Slf4JOutput implements Output { @Override public void write(final LogContext log) { final LogLevel level = log.level(); final Throwable throwable = log.throwable(); final ArrayList<Throwable> suppressedThrowables = log.suppressedThrowables(); if (throwable != null && suppressedThrowables != null) { for (Throwable t : suppressedThrowables) { throwable.addSuppressed(t); } } switch (level != null ? level : LogLevel.INFO) { case DEBUG: if (logger.isDebugEnabled()) { final String message = format(log); if (throwable != null) { logger.debug(message, throwable); } else { logger.debug(message); } } break; case INFO: if (logger.isInfoEnabled()) { final String message = format(log); if (throwable != null) { logger.info(message, throwable); } else { logger.info(message); } } break; case WARN: if (logger.isWarnEnabled()) { final String message = format(log); if (throwable != null) { logger.warn(message, throwable); } else { logger.warn(message); } } break; case ERROR: default: if (logger.isErrorEnabled()) { final String message = format(log); if (throwable != null) { logger.error(message, throwable); } else { logger.error(message); } } } } }
Slf4JOutput implements Output { @Override public void write(final LogContext log) { final LogLevel level = log.level(); final Throwable throwable = log.throwable(); final ArrayList<Throwable> suppressedThrowables = log.suppressedThrowables(); if (throwable != null && suppressedThrowables != null) { for (Throwable t : suppressedThrowables) { throwable.addSuppressed(t); } } switch (level != null ? level : LogLevel.INFO) { case DEBUG: if (logger.isDebugEnabled()) { final String message = format(log); if (throwable != null) { logger.debug(message, throwable); } else { logger.debug(message); } } break; case INFO: if (logger.isInfoEnabled()) { final String message = format(log); if (throwable != null) { logger.info(message, throwable); } else { logger.info(message); } } break; case WARN: if (logger.isWarnEnabled()) { final String message = format(log); if (throwable != null) { logger.warn(message, throwable); } else { logger.warn(message); } } break; case ERROR: default: if (logger.isErrorEnabled()) { final String message = format(log); if (throwable != null) { logger.error(message, throwable); } else { logger.error(message); } } } } Slf4JOutput(final Builder builder); }
Slf4JOutput implements Output { @Override public void write(final LogContext log) { final LogLevel level = log.level(); final Throwable throwable = log.throwable(); final ArrayList<Throwable> suppressedThrowables = log.suppressedThrowables(); if (throwable != null && suppressedThrowables != null) { for (Throwable t : suppressedThrowables) { throwable.addSuppressed(t); } } switch (level != null ? level : LogLevel.INFO) { case DEBUG: if (logger.isDebugEnabled()) { final String message = format(log); if (throwable != null) { logger.debug(message, throwable); } else { logger.debug(message); } } break; case INFO: if (logger.isInfoEnabled()) { final String message = format(log); if (throwable != null) { logger.info(message, throwable); } else { logger.info(message); } } break; case WARN: if (logger.isWarnEnabled()) { final String message = format(log); if (throwable != null) { logger.warn(message, throwable); } else { logger.warn(message); } } break; case ERROR: default: if (logger.isErrorEnabled()) { final String message = format(log); if (throwable != null) { logger.error(message, throwable); } else { logger.error(message); } } } } Slf4JOutput(final Builder builder); static Builder create(); @Override void write(final LogContext log); @Nonnull Logger getLogger(); @Nullable Format getFormat(); @Nullable Boolean getReplaceCrLf(); }
Slf4JOutput implements Output { @Override public void write(final LogContext log) { final LogLevel level = log.level(); final Throwable throwable = log.throwable(); final ArrayList<Throwable> suppressedThrowables = log.suppressedThrowables(); if (throwable != null && suppressedThrowables != null) { for (Throwable t : suppressedThrowables) { throwable.addSuppressed(t); } } switch (level != null ? level : LogLevel.INFO) { case DEBUG: if (logger.isDebugEnabled()) { final String message = format(log); if (throwable != null) { logger.debug(message, throwable); } else { logger.debug(message); } } break; case INFO: if (logger.isInfoEnabled()) { final String message = format(log); if (throwable != null) { logger.info(message, throwable); } else { logger.info(message); } } break; case WARN: if (logger.isWarnEnabled()) { final String message = format(log); if (throwable != null) { logger.warn(message, throwable); } else { logger.warn(message); } } break; case ERROR: default: if (logger.isErrorEnabled()) { final String message = format(log); if (throwable != null) { logger.error(message, throwable); } else { logger.error(message); } } } } Slf4JOutput(final Builder builder); static Builder create(); @Override void write(final LogContext log); @Nonnull Logger getLogger(); @Nullable Format getFormat(); @Nullable Boolean getReplaceCrLf();  }