@Beta @GwtCompatible public class TestLogHandler extends java.util.logging.Handler
TestLogHandler handler;
protected void setUp() throws Exception {
super.setUp();
handler = new TestLogHandler();
SomeClass.logger.addHandler(handler);
addTearDown(new TearDown() {
public void tearDown() throws Exception {
SomeClass.logger.removeHandler(handler);
}
});
}
public void test() {
SomeClass.foo();
LogRecord firstRecord = handler.getStoredLogRecords().get(0);
assertEquals("some message", firstRecord.getMessage());
}
| Constructor | Description |
|---|---|
TestLogHandler() |
| Modifier and Type | Method | Description |
|---|---|---|
void |
clear() |
|
void |
close() |
|
void |
flush() |
|
java.util.List<java.util.logging.LogRecord> |
getStoredLogRecords() |
Returns a snapshot of the logged records.
|
void |
publish(java.util.logging.LogRecord record) |
Adds the most recently logged record to our list.
|
public void publish(@Nullable
java.util.logging.LogRecord record)
publish in class java.util.logging.Handlerpublic void flush()
flush in class java.util.logging.Handlerpublic void close()
close in class java.util.logging.Handlerpublic void clear()
public java.util.List<java.util.logging.LogRecord> getStoredLogRecords()