Package org.apache.solr.util
Class ErrorLogMuter
java.lang.Object
org.apache.solr.util.ErrorLogMuter
- All Implemented Interfaces:
Closeable,AutoCloseable
Helper code for "Muting" ERROR log messages that you expect as a result of the things you are
testing, so they aren't a distraction in test logs. Example usage...
try (ErrorLogMuter errors = ErrorLogMuter.substring("nullfirst")) {
assertQEx( "invalid query format",
req( "q","id_i:1000", "sort", "nullfirst" ), 400 );
assertEquals(1, errors.getCount());
}
ERROR messages are considered a match if their input matches either the message String, or the
toString of an included Throwable, or any of the recursive Throwable.getCause()es of an included Throwable.
Matching ERROR messages are "muted" by filtering them out of the ROOT logger. Any Appenders attached to more specific Loggers may still include these "muted" ERRROR messages.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()intgetCount()The number of ERROR messages muted (by this instance) so far in it's lifecycle.static ErrorLogMuterMutes ERROR log messages that partially match the specified regex.static ErrorLogMuterMutes ERROR log messages that partially match the specified regex.static ErrorLogMuterMutes ERROR log messages that contain the input as a substring
-
Method Details
-
substring
Mutes ERROR log messages that contain the input as a substring -
regex
Mutes ERROR log messages that partially match the specified regex.- See Also:
-
regex
Mutes ERROR log messages that partially match the specified regex.- See Also:
-
getCount
public int getCount()The number of ERROR messages muted (by this instance) so far in it's lifecycle. This number may be less then the number of ERROR messages expected if multiple ErrorLogMuter objects are in use which match the same ERROR log messages -
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-