de.fhg.igd.logging.sun
Class AsynchronousStreamHandler

java.lang.Object
  extended byjava.util.logging.Handler
      extended byjava.util.logging.StreamHandler
          extended byde.fhg.igd.logging.sun.AsynchronousStreamHandler
All Implemented Interfaces:
Messenger

public class AsynchronousStreamHandler
extends StreamHandler
implements Messenger

This Handler is intended to be used for logging across slow or instable network connections. Because of the contained AbstractAsynchronousMessageDispatcher implementation, publish(java.util.logging.LogRecord) will always return immediately, to make sure the delay of the main thread caused by the logging mechanism is minimized even under unfavorable network conditions.

Version:
"$Id: AsynchronousStreamHandler.java 1913 2007-08-08 02:41:53Z jpeters $"
Author:
Matthias Pressfreund

Nested Class Summary
private static class AsynchronousStreamHandler.SunMessageDispatcher
          This is the dispatcher implementation for the Sun logging mechanism.
 
Field Summary
protected  boolean closed_
          This flag will be set to true once close() has been called
protected  AbstractAsynchronousMessageDispatcher dispatcher_
          The Asynchronous Message Dispatcher thread
 
Fields inherited from class java.util.logging.StreamHandler
 
Fields inherited from class java.util.logging.Handler
 
Constructor Summary
AsynchronousStreamHandler(OutputStream output, Formatter formatter, int maxbuf)
          Create an AsynchronousStreamHandler.
 
Method Summary
 void close()
          This method will close underlying streams and free used resources.
 void post(Object record)
          Actually post a message into the underlying logging system.
 void publish(LogRecord record)
          Hand over a log record to be posted as soon as possible.
 String toString()
           
 
Methods inherited from class java.util.logging.StreamHandler
flush, isLoggable, setEncoding, setOutputStream
 
Methods inherited from class java.util.logging.Handler
getEncoding, getErrorManager, getFilter, getFormatter, getLevel, reportError, setErrorManager, setFilter, setFormatter, setLevel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

dispatcher_

protected AbstractAsynchronousMessageDispatcher dispatcher_
The Asynchronous Message Dispatcher thread


closed_

protected boolean closed_
This flag will be set to true once close() has been called

Constructor Detail

AsynchronousStreamHandler

public AsynchronousStreamHandler(OutputStream output,
                                 Formatter formatter,
                                 int maxbuf)
Create an AsynchronousStreamHandler.

Parameters:
output - The underlying output stream
formatter - The log record formatter
maxbuf - The maximum number of messages that can be stored in the internal buffer (must be at least 1)
Throws:
IllegalArgumentException - if the maximum buffer size is less than 1
Method Detail

publish

public void publish(LogRecord record)
Hand over a log record to be posted as soon as possible.

Parameters:
record - The log record to be published

post

public void post(Object record)
Description copied from interface: Messenger
Actually post a message into the underlying logging system.

Specified by:
post in interface Messenger
Parameters:
record - The message to post

close

public void close()
This method will close underlying streams and free used resources. When it returns, all records will have been published by the included AbstractAsynchronousMessageDispatcher.


toString

public String toString()


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.