JBoss LogManager 1.1.0.CR6

org.jboss.logmanager.handlers
Class WriterHandler

java.lang.Object
  extended by java.util.logging.Handler
      extended by org.jboss.logmanager.ExtHandler
          extended by org.jboss.logmanager.handlers.WriterHandler
All Implemented Interfaces:
Flushable
Direct Known Subclasses:
OutputStreamHandler

public class WriterHandler
extends ExtHandler

A handler which writes to any Writer.


Field Summary
protected  Object outputLock
           
 
Fields inherited from class org.jboss.logmanager.ExtHandler
handlers, handlersUpdater
 
Constructor Summary
WriterHandler()
           
 
Method Summary
 void close()
          Close this logger.
protected  void doPublish(ExtLogRecord record)
          Do the actual work of publication; the record will have been filtered already.
 void flush()
          Flush this logger.
protected  void preWrite(ExtLogRecord record)
          Execute any pre-write policy, such as file rotation.
protected  void safeClose(Closeable c)
          Safely close the resource, reporting an error if the close fails.
 void setWriter(Writer writer)
          Set the writer.
 
Methods inherited from class org.jboss.logmanager.ExtHandler
addHandler, checkAccess, clearHandlers, getHandlers, isAutoFlush, publish, publish, removeHandler, setAutoFlush, setHandlers
 
Methods inherited from class java.util.logging.Handler
getEncoding, getErrorManager, getFilter, getFormatter, getLevel, isLoggable, reportError, setEncoding, setErrorManager, setFilter, setFormatter, setLevel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

outputLock

protected final Object outputLock
Constructor Detail

WriterHandler

public WriterHandler()
Method Detail

doPublish

protected void doPublish(ExtLogRecord record)
Do the actual work of publication; the record will have been filtered already. The default implementation does nothing except to flush if the autoFlush property is set to true; if this behavior is to be preserved in a subclass then this method should be called after the record is physically written.

Overrides:
doPublish in class ExtHandler
Parameters:
record - the log record to publish

preWrite

protected void preWrite(ExtLogRecord record)
Execute any pre-write policy, such as file rotation. The write lock is held during this method, so make it quick. The default implementation does nothing.

Parameters:
record - the record about to be logged

setWriter

public void setWriter(Writer writer)
Set the writer. The writer will then belong to this handler; when the handler is closed or a new writer is set, this writer will be closed.

Parameters:
writer - the new writer, or null to disable logging

flush

public void flush()
Flush this logger.

Specified by:
flush in interface Flushable
Specified by:
flush in class Handler

close

public void close()
           throws SecurityException
Close this logger.

Specified by:
close in class Handler
Throws:
SecurityException - if the caller does not have sufficient permission

safeClose

protected void safeClose(Closeable c)
Safely close the resource, reporting an error if the close fails.

Parameters:
c - the resource

JBoss LogManager 1.1.0.CR6

Copyright © 2009 JBoss, a division of Red Hat, Inc.