public class IntervalLogger extends Object implements Logger
Logger used by IRI that implements a logic to rate limits
the output on the console.
Instead of printing all messages immediately and unnecessarily spamming the console, it only prints messages every
few seconds and if the message has changed since the last output.| Constructor and Description |
|---|
IntervalLogger(Class<?> clazz)
Does the same as
IntervalLogger(Class, int) but defaults to the DEFAULT_LOG_INTERVAL for the
interval. |
IntervalLogger(Class<?> clazz,
int logInterval)
Does the same as
IntervalLogger(org.slf4j.Logger, int) but creates a new logback logger for the given
class. |
IntervalLogger(org.slf4j.Logger delegate)
Does the same as
IntervalLogger(org.slf4j.Logger, int) but defaults to the DEFAULT_LOG_INTERVAL
for the interval. |
IntervalLogger(org.slf4j.Logger delegate,
int logInterval)
Creates a
Logger for the given class that prints messages only every logInterval milliseconds. |
| Modifier and Type | Method and Description |
|---|---|
IntervalLogger |
debug(String message)
This method allows us to set a new debug message that shall get printed to the screen.
|
org.slf4j.Logger |
delegate()
This method returns the underlying logback Logger.
It can be used to issue log entries directly to the underlying logger without interfering with the logic of this class. |
IntervalLogger |
error(String message)
This method allows us to set a new error message that shall get printed to the screen.
|
IntervalLogger |
error(String message,
Throwable cause)
This method allows us to set a new error message that shall get printed to the screen.
|
boolean |
getEnabled()
This method is the getter for the enabled flag of the logger.
|
IntervalLogger |
info(String message)
This method allows us to set a new info message that shall get printed to the screen.
|
IntervalLogger |
setEnabled(boolean enabled)
This method is the setter for the enabled flag of the logger.
|
void |
triggerOutput()
Does the same as
triggerOutput(boolean) but defaults to letting the logger decide when to print the
message. |
void |
triggerOutput(boolean printImmediately)
Triggers the output of the last received message.
|
public IntervalLogger(Class<?> clazz)
IntervalLogger(Class, int) but defaults to the DEFAULT_LOG_INTERVAL for the
interval.clazz - class that is used to identify the origin of the log messagespublic IntervalLogger(org.slf4j.Logger delegate)
IntervalLogger(org.slf4j.Logger, int) but defaults to the DEFAULT_LOG_INTERVAL
for the interval.delegate - logback logger for issuing the messagespublic IntervalLogger(Class<?> clazz, int logInterval)
IntervalLogger(org.slf4j.Logger, int) but creates a new logback logger for the given
class.clazz - class that is used to identify the origin of the log messageslogInterval - time in milliseconds between log messagespublic IntervalLogger(org.slf4j.Logger delegate,
int logInterval)
Logger for the given class that prints messages only every logInterval milliseconds.
It simply stores the passed in parameters in its private properties to be able to access them later on.delegate - logback logger for issuing the messageslogInterval - time in milliseconds between log messagespublic org.slf4j.Logger delegate()
public IntervalLogger info(String message)
public IntervalLogger debug(String message)
public IntervalLogger error(String message)
public IntervalLogger error(String message, Throwable cause)
public boolean getEnabled()
getEnabled in interface Loggerpublic IntervalLogger setEnabled(boolean enabled)
setEnabled in interface Loggerenabled - true if the logger shall output messages and false otherwise (the logger is enabled by default)public void triggerOutput()
triggerOutput(boolean) but defaults to letting the logger decide when to print the
message.public void triggerOutput(boolean printImmediately)
printImmediately - flag indicating if the messages should be scheduled or printed immediatelyCopyright © 2019. All rights reserved.