public class LogReceiver
extends java.lang.Object
For a client of this class to consume these log messages,
method getLogQueue() provides a BlockingQueue
from which the client can extract the messages.
Before log messages can be received, #initialize(ORB, Manager) must be called.
To disconnect from the the log stream, call stop().
As an alternative to getLogQueue and stop,
this class also offers the method pair startCaptureLogs(PrintWriter)
and stopCaptureLogs(). These methods can be used to directly
print the received log messages to some writer, sparing the effort of listening on the LogQueue.
Method stopCaptureLogs() must be called in that case to stop capturing logs.
| Modifier and Type | Class and Description |
|---|---|
static class |
LogReceiver.DelayedLogEntry
Wraps an
ILogEntry for storage in a DelayQueue. |
static class |
LogReceiver.ReceivedLogRecord
A jlog-independent representation of the log record we received
|
| Modifier and Type | Field and Description |
|---|---|
protected LCEngine |
lct |
protected alma.acs.logging.engine.LogReceiver.MyRemoteResponseCallback |
rrc |
| Constructor and Description |
|---|
LogReceiver() |
| Modifier and Type | Method and Description |
|---|---|
long |
getDelayMillis() |
java.util.concurrent.BlockingQueue<LogReceiver.DelayedLogEntry> |
getLogQueue()
Gets access to the log record queue, from which the time-sorted log records should be fetched.
|
java.lang.String[] |
getStatusReports()
Gets the status reports.
|
boolean |
initialize()
Initializes the connection to the logging channel, which leads
to log entries getting written to the sorting queue.
|
boolean |
initialize(org.omg.CORBA.ORB theORB,
Manager manager,
int timeoutSeconds)
Variant of
initialize() which takes an existing ORB and manager reference. |
boolean |
isInitialized() |
boolean |
isVerbose() |
void |
setDelayMillis(long newDelayMillis)
Sets the delay that a log record's timestamp must have with respect to the current system time
in order to be allowed to leave the sorting queue.
|
void |
setVerbose(boolean verbose) |
void |
startCaptureLogs(java.io.PrintWriter logWriter)
Convenience method to capture logs directly into a PrintWriter.
|
void |
startCaptureLogs(java.io.PrintWriter logWriter,
java.util.concurrent.ThreadFactory threadFactory)
Variant of
startCaptureLogs(PrintWriter) which takes an optional ThreadFactory
which will be used to create the thread that reads out the log queue. |
void |
stop()
Disconnects from the logging channel.
|
void |
stopCaptureLogs()
Stops capturing logs into the PrintWriter that was provided to
startCaptureLogs(PrintWriter)
or any of the related methods. |
protected LCEngine lct
protected alma.acs.logging.engine.LogReceiver.MyRemoteResponseCallback rrc
public boolean isVerbose()
public void setVerbose(boolean verbose)
public boolean initialize()
throws LogEngineException
#initialize(ORB, Manager) instead of this method.
This method attempts to wait for successful initialization for up to 10 seconds.
If initialization did not happen within this time, false is returned, otherwise true.
If you call this method, make sure to subsequently call
getLogQueue() and drain the queue at your own responsibility,
or to call startCaptureLogs(PrintWriter) (or startCaptureLogs(PrintWriter, ThreadFactory))
which will drain the queue automatically.
true if initialization was successful within at most 10 secondsLogEngineException - In case of error instantiating the LCEngineinitialize(ORB, Manager, int)public boolean initialize(org.omg.CORBA.ORB theORB,
Manager manager,
int timeoutSeconds)
throws LogEngineException
initialize() which takes an existing ORB and manager reference.
This method attempts to wait for successful initialization for up to timeoutSeconds seconds.
If initialization did not happen within this time, false is returned, otherwise true.
theORB - the fully functional ORB object to reuse, or null if an ORB should be createdmanager - reference to the acs manager, or null if this reference should be createdtimeoutSeconds - timeout for awaiting the successful initialization.timeoutSeconds seconds.LogEngineException - In case of error instantiating the LCEnginepublic boolean isInitialized()
public void setDelayMillis(long newDelayMillis)
newDelayMillis - the delay time in milliseconds.public long getDelayMillis()
public java.util.concurrent.BlockingQueue<LogReceiver.DelayedLogEntry> getLogQueue()
The queue elements are of type LogReceiver.DelayedLogEntry,
from which the log record can be extracted
using the method LogReceiver.DelayedLogEntry.getLogEntry().
public java.lang.String[] getStatusReports()
public void stop()
getLogQueue()
know that the show is over.public void startCaptureLogs(java.io.PrintWriter logWriter)
throws java.io.IOException
#initialize(ORB, Manager) must be called as a precondition.
Method stopCaptureLogs() must be called to stop writing logs to logWriter.
logWriter - java.io.IOExceptionpublic void startCaptureLogs(java.io.PrintWriter logWriter,
java.util.concurrent.ThreadFactory threadFactory)
throws java.io.IOException
startCaptureLogs(PrintWriter) which takes an optional ThreadFactory
which will be used to create the thread that reads out the log queue.
This method could be used if LogReceiver is run inside a container
or as part of a ComponentClientTestCase.java.io.IOExceptionpublic void stopCaptureLogs()
startCaptureLogs(PrintWriter)
or any of the related methods.
Even though the call to this method returns immediately, all log records that are
currently residing inside the queue will still be written out, waiting the due time to allow sorting them.