/** * @throws Exception thrown by {@link #perform()} - unchecked */ @Override public final void run() { try { perform(); } catch (Exception e) { throwUnchecked(e); } }
/** * @param toThrow The throwable that will be thrown, unwrapped and unchecked; must not be null * @throws NullPointerException if toThrow is null */ public static void throwUnchecked(final Throwable toThrow) { throwUnchecked(toThrow, null); }
/** * @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 static TestLoggerFactory getInstance() { return INSTANCE.call(); }
/** * 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); }
@Override public boolean apply(final FieldFacade field) { return field.isIdentityField(); } };
/** * @return the result of {@link #perform()} * @throws Exception thrown by {@link #perform()} */ @Override @SuppressWarnings("PMD.SignatureDeclareThrowsException") public final Void call() throws Exception { perform(); return null; }
@Override public FieldFacade apply(final Field field) { return new FieldFacade(field); } };
private Optional<Object> valueOf(final FieldFacade field) { return field.valueOn(this); }
@Override public String apply(final FieldFacade field) { return field.getName() + "=" + valueOf(field).or("absent"); } };
@Override protected boolean matchesSafely(final T item, final Description mismatchDescription) { final boolean matches = modifier.existsOn(item); if (!matches) { mismatchDescription.appendValue(item).appendText(" did not have modifier ").appendValue(modifier); } return matches; }
/** * 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 static TestLoggerFactory getInstance() { return INSTANCE.call(); }
/** * @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 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); }
@SuppressWarnings("unchecked") public void setContextMap(final Map contextMap) { value.set(new HashMap<String, String>(contextMap)); } }
/** * @return whether this logger is info enabled in this thread */ @Override public boolean isInfoEnabled() { return enabledLevels.get().contains(INFO); }
/** * @return whether this logger is trace enabled in this thread */ @Override public boolean isTraceEnabled() { return enabledLevels.get().contains(TRACE); }
@Override public boolean isInfoEnabled(final Marker marker) { return enabledLevels.get().contains(INFO); }