Logger { public boolean isLoggable(Level level) { if (level.intValue() >= Level.SEVERE.intValue()) { return slf4jLogger.isErrorEnabled(); } else if (level.intValue() >= Level.WARNING.intValue()) { return slf4jLogger.isWarnEnabled(); } else if (level.intValue() >= Level.CONFIG.intValue()) { return slf4jLogger.isInfoEnabled(); } else if (level.intValue() >= Level.FINE.intValue()) { return slf4jLogger.isDebugEnabled(); } else { return slf4jLogger.isTraceEnabled(); } } private  Logger(String name); @VisibleForTesting  Logger(org.slf4j.Logger logger); static Logger getLogger(String name); static Logger getLogger(String name,
            @SuppressWarnings("unused") String resourceBundleName); String getName(); void severe(String msg); void warning(String msg); void info(String msg); void config(String msg); void fine(String msg); void finer(String msg); void finest(String msg); void log(LogRecord record); void log(Level level, String msg); void log(Level level, String msg, @Nullable Object param1); void log(Level level, String msg, @Nullable Object[] params); void log(Level level, String msg, Throwable thrown); boolean isLoggable(Level level); Level getLevel(); @SuppressWarnings("unused") void logp(Level level, String sourceClass, String sourceMethod, String msg); @SuppressWarnings("unused") void logp(Level level, String sourceClass, String sourceMethod, String msg,
            Object param1); @SuppressWarnings("unused") void logp(Level level, String sourceClass, String sourceMethod, String msg,
            Object[] params); @SuppressWarnings("unused") void logp(Level level, String sourceClass, String sourceMethod, String msg,
            Throwable thrown); @SuppressWarnings("unused") void logrb(Level level, String sourceClass, String sourceMethod, String bundleName,
            String msg); @SuppressWarnings("unused") void logrb(Level level, String sourceClass, String sourceMethod, String bundleName,
            String msg, Object param1); @SuppressWarnings("unused") void logrb(Level level, String sourceClass, String sourceMethod, String bundleName,
            String msg, Object[] params); @SuppressWarnings("unused") void logrb(Level level, String sourceClass, String sourceMethod, ResourceBundle bundle,
            String msg, Object... params); @SuppressWarnings("unused") void logrb(Level level, ResourceBundle bundle, String msg, Object... params); @SuppressWarnings("unused") void logrb(Level level, String sourceClass, String sourceMethod, String bundleName,
            String msg, Throwable thrown); @SuppressWarnings("unused") void logrb(Level level, String sourceClass, String sourceMethod, ResourceBundle bundle,
            String msg, Throwable thrown); @SuppressWarnings("unused") void logrb(Level level, ResourceBundle bundle, String msg, Throwable thrown); @SuppressWarnings("unused") void entering(String sourceClass, String sourceMethod); @SuppressWarnings("unused") void entering(String sourceClass, String sourceMethod, Object param1); @SuppressWarnings("unused") void entering(String sourceClass, String sourceMethod, Object[] params); @SuppressWarnings("unused") void exiting(String sourceClass, String sourceMethod); @SuppressWarnings("unused") void exiting(String sourceClass, String sourceMethod, Object result); @SuppressWarnings("unused") void throwing(String sourceClass, String sourceMethod, Throwable thrown); @Nullable ResourceBundle getResourceBundle(); void setResourceBundle(ResourceBundle resourceBundle); @Nullable String getResourceBundleName(); Logger getParent(); void setParent(@SuppressWarnings("unused") Logger parent); void setLevel(@SuppressWarnings("unused") Level newLevel); static Logger getAnonymousLogger(); static Logger getAnonymousLogger(@SuppressWarnings("unused") String resourceBundleName); static final Logger getGlobal(); static final String GLOBAL_LOGGER_NAME; static final Logger global; }
@Test public void testIsLoggableAll() { org.slf4j.Logger slf4jLogger = mock(org.slf4j.Logger.class); when(slf4jLogger.isTraceEnabled()).thenReturn(true); when(slf4jLogger.isDebugEnabled()).thenReturn(true); when(slf4jLogger.isInfoEnabled()).thenReturn(true); when(slf4jLogger.isWarnEnabled()).thenReturn(true); when(slf4jLogger.isErrorEnabled()).thenReturn(true); Logger logger = new Logger(slf4jLogger); assertThat(logger.isLoggable(Level.SEVERE)).isTrue(); assertThat(logger.isLoggable(Level.WARNING)).isTrue(); assertThat(logger.isLoggable(Level.INFO)).isTrue(); assertThat(logger.isLoggable(Level.CONFIG)).isTrue(); assertThat(logger.isLoggable(Level.FINE)).isTrue(); assertThat(logger.isLoggable(Level.FINER)).isTrue(); assertThat(logger.isLoggable(Level.FINEST)).isTrue(); }
@Test public void testIsLoggableSome() { org.slf4j.Logger slf4jLogger = mock(org.slf4j.Logger.class); when(slf4jLogger.isTraceEnabled()).thenReturn(false); when(slf4jLogger.isDebugEnabled()).thenReturn(false); when(slf4jLogger.isInfoEnabled()).thenReturn(false); when(slf4jLogger.isWarnEnabled()).thenReturn(true); when(slf4jLogger.isErrorEnabled()).thenReturn(true); Logger logger = new Logger(slf4jLogger); assertThat(logger.isLoggable(Level.SEVERE)).isTrue(); assertThat(logger.isLoggable(Level.WARNING)).isTrue(); assertThat(logger.isLoggable(Level.INFO)).isFalse(); assertThat(logger.isLoggable(Level.CONFIG)).isFalse(); assertThat(logger.isLoggable(Level.FINE)).isFalse(); assertThat(logger.isLoggable(Level.FINER)).isFalse(); assertThat(logger.isLoggable(Level.FINEST)).isFalse(); }
@Test public void testIsLoggableNone() { org.slf4j.Logger slf4jLogger = mock(org.slf4j.Logger.class); when(slf4jLogger.isTraceEnabled()).thenReturn(false); when(slf4jLogger.isDebugEnabled()).thenReturn(false); when(slf4jLogger.isInfoEnabled()).thenReturn(false); when(slf4jLogger.isWarnEnabled()).thenReturn(false); when(slf4jLogger.isErrorEnabled()).thenReturn(false); Logger logger = new Logger(slf4jLogger); assertThat(logger.isLoggable(Level.SEVERE)).isFalse(); assertThat(logger.isLoggable(Level.WARNING)).isFalse(); assertThat(logger.isLoggable(Level.INFO)).isFalse(); assertThat(logger.isLoggable(Level.CONFIG)).isFalse(); assertThat(logger.isLoggable(Level.FINE)).isFalse(); assertThat(logger.isLoggable(Level.FINER)).isFalse(); assertThat(logger.isLoggable(Level.FINEST)).isFalse(); }