Classes | |
class | DelayedLogEntry |
class | MyRemoteResponseCallback |
class | ReceivedLogRecord |
Public Member Functions | |
LogReceiver () | |
boolean | isVerbose () |
void | setVerbose (boolean verbose) |
boolean | initialize () |
boolean | initialize (ORB theORB, Manager manager, int timeoutSeconds) |
boolean | isInitialized () |
void | setDelayMillis (long newDelayMillis) |
long | getDelayMillis () |
BlockingQueue< DelayedLogEntry > | getLogQueue () |
String[] | getStatusReports () |
void | stop () |
void | startCaptureLogs (final PrintWriter logWriter) throws IOException |
void | startCaptureLogs (final PrintWriter logWriter, ThreadFactory threadFactory) throws IOException |
void | stopCaptureLogs () |
Protected Attributes | |
LCEngine | lct |
MyRemoteResponseCallback | rrc |
Receives log messages from the ACS Log service and sorts them by timestamp, even if the log messages arrive in different order within a certain time window.
For a client of this class to consume these log messages, method getLogQueue() provides a java.util.concurrent.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.
alma.acs.logging.engine.LogReceiver.LogReceiver | ( | ) |
long alma.acs.logging.engine.LogReceiver.getDelayMillis | ( | ) |
Referenced by alma.acs.logging.engine.LogReceiver.stopCaptureLogs().
BlockingQueue<DelayedLogEntry> alma.acs.logging.engine.LogReceiver.getLogQueue | ( | ) |
Gets access to the log record queue, from which the time-sorted log records should be fetched.
The queue elements are of type DelayedLogEntry, from which the log record can be extracted using the method DelayedLogEntry#getLogEntry().
Referenced by alma.acs.logging.engine.LogReceiver.startCaptureLogs().
String [] alma.acs.logging.engine.LogReceiver.getStatusReports | ( | ) |
Gets the status reports. Currently only a forceful disconnect would be shown, the rest is ignored. TODO: separate good and bad status reports
boolean alma.acs.logging.engine.LogReceiver.initialize | ( | ORB | theORB, | |
Manager | manager, | |||
int | timeoutSeconds | |||
) |
Variant of 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 created | |
manager | reference to the acs manager, or null if this reference should be created | |
timeoutSeconds | timeout for awaiting the successful initialization. |
timeoutSeconds
seconds. References com.cosylab.logging.engine.ACS.LCEngine.addLogConnectionListener(), com.cosylab.logging.engine.ACS.LCEngine.addLogListener(), com.cosylab.logging.engine.ACS.LCEngine.connect(), alma.acs.logging.engine.LogReceiver.lct, alma.acs.logging.engine.LogReceiver.rrc, and com.cosylab.logging.engine.ACS.LCEngine.setAccessType().
boolean alma.acs.logging.engine.LogReceiver.initialize | ( | ) |
Initializes the connection to the logging channel, which leads to log entries getting written to the sorting queue. To reuse an existing ORB and manager reference, use 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.
Referenced by alma.acs.component.client.ComponentClientTestCase.getLogReceiver().
boolean alma.acs.logging.engine.LogReceiver.isInitialized | ( | ) |
boolean alma.acs.logging.engine.LogReceiver.isVerbose | ( | ) |
void alma.acs.logging.engine.LogReceiver.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.
newDelayMillis | the delay time in milliseconds. |
References alma.acs.logging.engine.LogReceiver.rrc.
void alma.acs.logging.engine.LogReceiver.setVerbose | ( | boolean | verbose | ) |
void alma.acs.logging.engine.LogReceiver.startCaptureLogs | ( | final PrintWriter | logWriter | ) | throws IOException |
Convenience method to capture logs directly into a PrintWriter. Method initialize(ORB, Manager) must be called as a precondition. Method stopCaptureLogs() must be called to stop writing logs to logWriter
.
logWriter |
IOException |
void alma.acs.logging.engine.LogReceiver.startCaptureLogs | ( | final PrintWriter | logWriter, | |
ThreadFactory | threadFactory | |||
) | throws IOException |
Variant of 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.
References alma.acs.logging.engine.LogReceiver.getLogQueue(), alma.acs.logging.engine.LogReceiver.isInitialized(), alma.acs.logging.engine.LogReceiver.stop(), and com.cosylab.logging.engine.log.ILogEntry.toXMLString().
void alma.acs.logging.engine.LogReceiver.stop | ( | ) |
Disconnects from the logging channel. A special "queue poison" version of DelayedLogEntry will be added to the queue with zero delay, so that all clients who fetch log recored of the queue obtained from getLogQueue() know that the show is over.
References com.cosylab.logging.engine.ACS.LCEngine.close(), and alma.acs.logging.engine.LogReceiver.lct.
Referenced by alma.acs.logging.engine.LogReceiver.startCaptureLogs(), and alma.acs.component.client.ComponentClientTestCase.tearDown().
void alma.acs.logging.engine.LogReceiver.stopCaptureLogs | ( | ) |
Stops capturing logs into the PrintWriter that was provided to 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.
References alma.acs.logging.engine.LogReceiver.getDelayMillis().
LCEngine alma.acs.logging.engine.LogReceiver.lct [protected] |
MyRemoteResponseCallback alma.acs.logging.engine.LogReceiver.rrc [protected] |