@Test public void loggingAccordingToLevel() { LoggerChannel loggerTrace = mock(LoggerChannel.class); LoggerChannel loggerInfo = mock(LoggerChannel.class); LoggerChannel loggerError = mock(LoggerChannel.class); PluggableLoggerFactory factory = new PluggableLoggerFactory(); factory.addLogger(loggerInfo, Level.INFO); factory.addLogger(loggerError, Level.ERROR); factory.addLogger(loggerTrace, Level.TRACE); Logger logger = factory.getLogger("test"); logger.error("test"); logger.info("test"); logger.trace("test"); verify(loggerTrace, times(3)).log(Mockito.any(Level.class), anyString(), Mockito.any(Marker.class), anyString(), Mockito.any(Throwable.class)); verify(loggerInfo, times(2)).log(Mockito.any(Level.class), anyString(), Mockito.any(Marker.class), anyString(), Mockito.any(Throwable.class)); verify(loggerError, times(1)).log(Mockito.any(Level.class), anyString(), Mockito.any(Marker.class), anyString(), Mockito.any(Throwable.class)); }
public PluggableLoggerFactory addLogger(LoggerChannel logger, Level level) { mSortedLoggers.add(new SortedLogger(logger, level.toInt())); Collections.sort(mSortedLoggers, mSortedLoggersComparator); return this; }
PluggableLoggerFactory extends AbstractSimpleLoggerFactory { public PluggableLoggerFactory addLogger(LoggerChannel logger, Level level) { mSortedLoggers.add(new SortedLogger(logger, level.toInt())); Collections.sort(mSortedLoggers, mSortedLoggersComparator); return this; } }
PluggableLoggerFactory extends AbstractSimpleLoggerFactory { public PluggableLoggerFactory addLogger(LoggerChannel logger, Level level) { mSortedLoggers.add(new SortedLogger(logger, level.toInt())); Collections.sort(mSortedLoggers, mSortedLoggersComparator); return this; }  }
PluggableLoggerFactory extends AbstractSimpleLoggerFactory { public PluggableLoggerFactory addLogger(LoggerChannel logger, Level level) { mSortedLoggers.add(new SortedLogger(logger, level.toInt())); Collections.sort(mSortedLoggers, mSortedLoggersComparator); return this; }  @Override Logger generateLogger(String name); PluggableLoggerFactory removeAll(); PluggableLoggerFactory addLogger(LoggerChannel logger, Level level); }
PluggableLoggerFactory extends AbstractSimpleLoggerFactory { public PluggableLoggerFactory addLogger(LoggerChannel logger, Level level) { mSortedLoggers.add(new SortedLogger(logger, level.toInt())); Collections.sort(mSortedLoggers, mSortedLoggersComparator); return this; }  @Override Logger generateLogger(String name); PluggableLoggerFactory removeAll(); PluggableLoggerFactory addLogger(LoggerChannel logger, Level level);  }