Package adams.core.logging
Class MultiHandler
- java.lang.Object
-
- java.util.logging.Handler
-
- adams.core.logging.AbstractLogHandler
-
- adams.core.logging.MultiHandler
-
- All Implemented Interfaces:
Comparable<Handler>
public class MultiHandler extends AbstractLogHandler
Combines multiple handlers.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
-
-
Field Summary
Fields Modifier and Type Field Description protected Handler[]
m_Handlers
the logging handlers to use.-
Fields inherited from class adams.core.logging.AbstractLogHandler
m_LoggingListeners, m_LogUsed
-
-
Constructor Summary
Constructors Constructor Description MultiHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addHandler(Handler value)
Adds the specified handler.void
close()
Close the Handler and free all associated resources.int
compareTo(Handler o)
Compares the handler with itself.protected void
doPublish(LogRecord record)
Publish a LogRecord.void
flush()
Flush any buffered output.Handler[]
getHandlers()
Returns the current handlers.protected void
initialize()
Initializes the members.void
removeHandler(int index)
Removes the specified handler.void
setHandlers(Handler[] value)
Sets the handlers to use.-
Methods inherited from class adams.core.logging.AbstractLogHandler
addLoggingListener, equals, iterator, loggingListeners, notifyLoggingListeners, postPublish, publish, removeLoggingListener, removeLoggingListeners, reset, setUp
-
Methods inherited from class java.util.logging.Handler
getEncoding, getErrorManager, getFilter, getFormatter, getLevel, isLoggable, reportError, setEncoding, setErrorManager, setFilter, setFormatter, setLevel
-
-
-
-
Field Detail
-
m_Handlers
protected Handler[] m_Handlers
the logging handlers to use.
-
-
Method Detail
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initialize
in classAbstractLogHandler
-
setHandlers
public void setHandlers(Handler[] value)
Sets the handlers to use.- Parameters:
value
- the handlers
-
getHandlers
public Handler[] getHandlers()
Returns the current handlers.- Returns:
- the handlers
-
addHandler
public void addHandler(Handler value)
Adds the specified handler.- Parameters:
value
- the handler
-
removeHandler
public void removeHandler(int index)
Removes the specified handler.- Parameters:
index
- the handler index
-
flush
public void flush()
Flush any buffered output.- Overrides:
flush
in classAbstractLogHandler
-
close
public void close() throws SecurityException
Close the Handler and free all associated resources.The close method will perform a flush and then close the Handler. After close has been called this Handler should no longer be used. Method calls may either be silently ignored or may throw runtime exceptions.
- Overrides:
close
in classAbstractLogHandler
- Throws:
SecurityException
- if a security manager exists and if the caller does not have LoggingPermission("control").
-
doPublish
protected void doPublish(LogRecord record)
Publish a LogRecord.The logging request was made initially to a Logger object, which initialized the LogRecord and forwarded it here.
The Handler is responsible for formatting the message, when and if necessary. The formatting should include localization.
- Specified by:
doPublish
in classAbstractLogHandler
- Parameters:
record
- description of the log event. A null record is silently ignored and is not published
-
compareTo
public int compareTo(Handler o)
Compares the handler with itself.- Specified by:
compareTo
in interfaceComparable<Handler>
- Overrides:
compareTo
in classAbstractLogHandler
- Parameters:
o
- the other handler- Returns:
- less than 0, equal to 0, or greater than 0 if the handler is less, equal to, or greater than this one
-
-