Package org.graylog2.utilities
Class LoggingServiceListener
java.lang.Object
com.google.common.util.concurrent.Service.Listener
org.graylog2.utilities.LoggingServiceListener
public class LoggingServiceListener
extends com.google.common.util.concurrent.Service.Listener
This class is a convenience listener for
It allows adding an action that is run when the service transitions into
Service
instances so that service lifecycle changes can easily
be logged without having to manually write listeners everywhere.
It allows adding an action that is run when the service transitions into
Service.State.RUNNING
as that is
the most common case. If you need additional, or more complex listeners, add a new instance in addition to this simple
class.-
Constructor Summary
ConstructorDescriptionLoggingServiceListener
(String serviceName, String id) Creates a new logging listener for the service name and an id.LoggingServiceListener
(String serviceName, String id, @NotNull org.slf4j.Logger logger) LoggingServiceListener
(String serviceName, String id, Runnable action, @NotNull org.slf4j.Logger logger) -
Method Summary
-
Constructor Details
-
LoggingServiceListener
Creates a new logging listener for the service name and an id.- Parameters:
serviceName
- the concise name describing the service being listened to (e.g. "Input" or "Cache")id
- the unique id of the service instance, useful if there are more than one running.
-
LoggingServiceListener
-
LoggingServiceListener
-
-
Method Details
-
starting
public void starting()- Overrides:
starting
in classcom.google.common.util.concurrent.Service.Listener
-
running
public void running()- Overrides:
running
in classcom.google.common.util.concurrent.Service.Listener
-
stopping
public void stopping(com.google.common.util.concurrent.Service.State from) - Overrides:
stopping
in classcom.google.common.util.concurrent.Service.Listener
-
terminated
public void terminated(com.google.common.util.concurrent.Service.State from) - Overrides:
terminated
in classcom.google.common.util.concurrent.Service.Listener
-
failed
- Overrides:
failed
in classcom.google.common.util.concurrent.Service.Listener
-