/** * The conventional hierarchical notion of Levels, where info being enabled implies warn and error being enabled, is not a * requirement of the SLF4J API, so all levels you wish to enable must be passed explicitly to this method. If you wish to * use traditional hierarchical setups you may conveniently do so by using the constants in * {@link uk.org.lidalia.slf4jext.ConventionalLevelHierarchy} * * @param enabledLevels levels which will be considered enabled for this logger IN THIS THREAD; * does not affect enabled levels for this logger in other threads */ public void setEnabledLevels(final ImmutableSet<Level> enabledLevels) { this.enabledLevels.set(enabledLevels); }
/** * The conventional hierarchical notion of Levels, where info being enabled implies warn and error being enabled, is not a * requirement of the SLF4J API, so all levels you wish to enable must be passed explicitly to this method. If you wish to * use traditional hierarchical setups you may conveniently do so by using the constants in * {@link uk.org.lidalia.slf4jext.ConventionalLevelHierarchy} * * @param enabledLevelsForAllThreads levels which will be considered enabled for this logger IN ALL THREADS */ public void setEnabledLevelsForAllThreads(final ImmutableSet<Level> enabledLevelsForAllThreads) { this.enabledLevels = new ThreadLocal<>(enabledLevelsForAllThreads); }
/** * @return the set of levels enabled for this logger on this thread */ public ImmutableSet<Level> getEnabledLevels() { return enabledLevels.get(); }
/** * Removes ALL {@link LoggingEvent}s logged on this logger, regardless of thread, * and resets the enabled levels of the logger to {@link uk.org.lidalia.slf4jext.Level#enablableValueSet()} * for ALL threads. */ public void clearAll() { allLoggingEvents.clear(); loggingEvents.reset(); enabledLevels.reset(); }
/** * Removes ALL {@link LoggingEvent}s logged on this logger, regardless of thread, * and resets the enabled levels of the logger to {@link uk.org.lidalia.slf4jext.Level#enablableValueSet()} * for ALL threads. */ public void clearAll() { allLoggingEvents.clear(); loggingEvents.reset(); enabledLevels.reset(); }
/** * @return the set of levels enabled for this logger on this thread */ public ImmutableSet<Level> getEnabledLevels() { return enabledLevels.get(); }
/** * The conventional hierarchical notion of Levels, where info being enabled implies warn and error being enabled, is not a * requirement of the SLF4J API, so all levels you wish to enable must be passed explicitly to this method. If you wish to * use traditional hierarchical setups you may conveniently do so by using the constants in * {@link uk.org.lidalia.slf4jext.ConventionalLevelHierarchy} * * @param enabledLevels levels which will be considered enabled for this logger IN THIS THREAD; * does not affect enabled levels for this logger in other threads */ public void setEnabledLevels(final ImmutableSet<Level> enabledLevels) { this.enabledLevels.set(enabledLevels); }
public void clearAllLoggers() { for (final TestLogger testLogger: loggers.values()) { testLogger.clearAll(); } loggingEvents.reset(); allLoggingEvents.clear(); }
/** * The conventional hierarchical notion of Levels, where info being enabled implies warn and error being enabled, is not a * requirement of the SLF4J API, so all levels you wish to enable must be passed explicitly to this method. If you wish to * use traditional hierarchical setups you may conveniently do so by using the constants in * {@link uk.org.lidalia.slf4jext.ConventionalLevelHierarchy} * * @param enabledLevelsForAllThreads levels which will be considered enabled for this logger IN ALL THREADS */ public void setEnabledLevelsForAllThreads(final ImmutableSet<Level> enabledLevelsForAllThreads) { this.enabledLevels = new ThreadLocal<>(enabledLevelsForAllThreads); }
/** * @return whether this logger is trace enabled in this thread */ @Override public boolean isTraceEnabled() { return enabledLevels.get().contains(TRACE); }
@SuppressWarnings("unchecked") public void setContextMap(final Map contextMap) { value.set(new HashMap<String, String>(contextMap)); } }
public void clearAllLoggers() { for (final TestLogger testLogger: loggers.values()) { testLogger.clearAll(); } loggingEvents.reset(); allLoggingEvents.clear(); }
/** * @return whether this logger is info enabled in this thread */ @Override public boolean isInfoEnabled() { return enabledLevels.get().contains(INFO); }
@SuppressWarnings("unchecked") public void setContextMap(final Map contextMap) { value.set(new HashMap<String, String>(contextMap)); } }
@Override public boolean isInfoEnabled(final Marker marker) { return enabledLevels.get().contains(INFO); }
@Override public T get() { final T initialValue = initialValueCreator.get(); set(initialValue); return initialValue; } };
/** * @return whether this logger is trace enabled in this thread */ @Override public boolean isTraceEnabled() { return enabledLevels.get().contains(TRACE); }
/** * @return whether this logger is error enabled in this thread */ @Override public boolean isErrorEnabled() { return enabledLevels.get().contains(ERROR); }