public class QueueLogger extends Object implements Logger
Logger interface that queues LogItem objects for processing later, or in another thread.
The underlying queue implementation is ConcurrentLinkedQueue meaning that log items can safely be produced and consumed in separate threads.
Note that each logging level can be enabled independently in this implementation. All levels are enabled by default.
| Constructor and Description |
|---|
QueueLogger()
Constructs a new
QueueLogger with a new queue. |
QueueLogger(java.util.concurrent.ConcurrentLinkedQueue<LogItem> queue)
Constructs a new
QueueLogger using the specified queue. |
| Modifier and Type | Method and Description |
|---|---|
void |
debug(String message)
|
void |
error(String message)
|
java.util.concurrent.ConcurrentLinkedQueue<LogItem> |
getQueue()
Returns the queue of
LogItems. |
void |
info(String message)
|
boolean |
isDebugEnabled()
Indicates whether logging events at the DEBUG level are queued.
|
boolean |
isErrorEnabled()
Indicates whether logging events at the ERROR level are queued.
|
boolean |
isInfoEnabled()
Indicates whether logging events at the INFO level are queued.
|
boolean |
isWarnEnabled()
Indicates whether logging events at the WARNING level are queued.
|
void |
outputTo(Logger logger)
|
void |
setDebugEnabled(boolean debugEnabled)
Sets whether logging events at the DEBUG level are queued.
|
void |
setErrorEnabled(boolean errorEnabled)
Sets whether logging events at the ERROR level are queued.
|
void |
setInfoEnabled(boolean infoEnabled)
Sets whether logging events at the INFO level are queued.
|
void |
setWarnEnabled(boolean warnEnabled)
Sets whether logging events at the WARNING level are queued.
|
void |
warn(String message)
|
public java.util.concurrent.ConcurrentLinkedQueue<LogItem> getQueue()
LogItems.
Because the queue implementation is ConcurrentLinkedQueue, the log items can safely be produced and consumed in separate threads.
LogItems.public void error(String message)
public void warn(String message)
public void info(String message)
public void debug(String message)
public boolean isErrorEnabled()
isErrorEnabled in interface Loggertrue if logging events at the ERROR level are queued, otherwise false.public void setErrorEnabled(boolean errorEnabled)
errorEnabled - determines whether logging events at the ERROR level are queued.public boolean isWarnEnabled()
isWarnEnabled in interface Loggertrue if logging events at the WARNING level are queued, otherwise false.public void setWarnEnabled(boolean warnEnabled)
warnEnabled - determines whether logging events at the WARNING level are queued.public boolean isInfoEnabled()
isInfoEnabled in interface Loggertrue if logging events at the INFO level are queued, otherwise false.public void setInfoEnabled(boolean infoEnabled)
infoEnabled - determines whether logging events at the INFO level are queued.public boolean isDebugEnabled()
isDebugEnabled in interface Loggertrue if logging events at the DEBUG level are queued, otherwise false.public void setDebugEnabled(boolean debugEnabled)
debugEnabled - determines whether logging events at the DEBUG level are queued.