public abstract class LogListener extends Object implements AutoCloseable
LogListener class is the base class for an object that is called for every log event. It is intended to
be used only in unit tests.
The constructor adds the object to a static list of listeners; the Logger classes will check for the presence
of listeners and invoke them as required.| Constructor and Description |
|---|
LogListener()
Construct a
LogListener - add the listener to the list of listeners. |
| Modifier and Type | Method and Description |
|---|---|
static void |
add(LogListener listener)
Add a listener to the list.
|
void |
close()
Close the listener - remove it from the list.
|
static void |
invokeAll(Logger logger,
Level level,
String text,
Throwable throwable)
Invoke all listeners.
|
static boolean |
present()
Test whether listeners are present.
|
abstract void |
receive(Instant time,
Logger logger,
Level level,
String text,
Throwable throwable)
Receive a log event.
|
static void |
remove(LogListener listener)
Remove a listener from the list.
|
public LogListener()
LogListener - add the listener to the list of listeners.public void close()
close in interface AutoCloseablepublic abstract void receive(Instant time, Logger logger, Level level, String text, Throwable throwable)
time - the time of the eventlogger - the logger objectlevel - the logging leveltext - the text of the messagethrowable - a Throwable, if providedpublic static void add(LogListener listener)
listener - the listenerpublic static void remove(LogListener listener)
listener - the listenerpublic static boolean present()
true if listeners are presentCopyright © 2021. All rights reserved.