Package org.jboss.logmanager.handlers
Class WriterHandler
- java.lang.Object
-
- java.util.logging.Handler
-
- org.jboss.logmanager.ExtHandler
-
- org.jboss.logmanager.handlers.WriterHandler
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.AutoCloseable
,FlushableCloseable
,Protectable
- Direct Known Subclasses:
OutputStreamHandler
public class WriterHandler extends ExtHandler
A handler which writes to anyWriter
.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.Object
outputLock
private java.io.Writer
writer
-
Fields inherited from class org.jboss.logmanager.ExtHandler
handlers, handlersUpdater
-
-
Constructor Summary
Constructors Constructor Description WriterHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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(java.io.Closeable c)
Safely close the resource, reporting an error if the close fails.private void
safeFlush(java.io.Flushable f)
void
setWriter(java.io.Writer writer)
Set the writer.private void
writeHead(java.io.Writer writer)
private void
writeTail(java.io.Writer writer)
-
Methods inherited from class org.jboss.logmanager.ExtHandler
addHandler, checkAccess, checkAccess, clearHandlers, disableAccess, enableAccess, getHandlers, isAutoFlush, isEnabled, protect, publish, publish, removeHandler, setAutoFlush, setEnabled, setEncoding, setErrorManager, setFilter, setFormatter, setHandlers, setLevel, unprotect
-
-
-
-
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 theautoFlush
property is set totrue
; 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 classExtHandler
- 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(java.io.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, ornull
to disable logging
-
writeHead
private void writeHead(java.io.Writer writer)
-
writeTail
private void writeTail(java.io.Writer writer)
-
flush
public void flush()
Flush this logger.- Specified by:
flush
in interfacejava.io.Flushable
- Overrides:
flush
in classExtHandler
-
close
public void close() throws java.lang.SecurityException
Close this logger.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classExtHandler
- Throws:
java.lang.SecurityException
- if the caller does not have sufficient permission
-
safeClose
protected void safeClose(java.io.Closeable c)
Safely close the resource, reporting an error if the close fails.- Parameters:
c
- the resource
-
safeFlush
private void safeFlush(java.io.Flushable f)
-
-