Package adams.core.logging
Class AbstractLogHandler
- java.lang.Object
-
- java.util.logging.Handler
-
- adams.core.logging.AbstractLogHandler
-
- All Implemented Interfaces:
Comparable<Handler>
- Direct Known Subclasses:
AbstractEnhancingSingleHandler
,ConsolePanelHandler
,FileHandler
,MultiHandler
,NullHandler
,RemoteSendHandler
,SimpleConsoleHandler
public abstract class AbstractLogHandler extends Handler implements Comparable<Handler>
Ancestor for log handlers.- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
-
-
Field Summary
Fields Modifier and Type Field Description protected HashSet<LoggingListener>
m_LoggingListeners
the log listeners.protected boolean
m_LogUsed
whether the log has been used.
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractLogHandler()
Initializes the log handler.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addLoggingListener(LoggingListener l)
Adds the specified logging listener.void
close()
Close the Handler and free all associated resources.int
compareTo(Handler o)
Compares the handler with itself.protected abstract void
doPublish(LogRecord record)
Publish a LogRecord.boolean
equals(Object obj)
Checks whether the provided object is the same as this handler.void
flush()
Flush any buffered output.protected void
initialize()
Initializes the members.Iterator<LoggingListener>
iterator()
Returns an iterator over all current logging listeners.Set<LoggingListener>
loggingListeners()
Returns an iterator over all current logging listeners.protected void
notifyLoggingListeners(LogRecord record)
Sends out the log record to its listeners.protected void
postPublish(LogRecord record)
Hook method after logging occurred.void
publish(LogRecord record)
Publish a LogRecord.void
removeLoggingListener(LoggingListener l)
Removes the specified logging listener.void
removeLoggingListeners()
Removes all logging listener.protected void
reset()
Resets the handler.protected void
setUp()
Hook method for performing setup before processing first log record.-
Methods inherited from class java.util.logging.Handler
getEncoding, getErrorManager, getFilter, getFormatter, getLevel, isLoggable, reportError, setEncoding, setErrorManager, setFilter, setFormatter, setLevel
-
-
-
-
Field Detail
-
m_LoggingListeners
protected HashSet<LoggingListener> m_LoggingListeners
the log listeners.
-
m_LogUsed
protected boolean m_LogUsed
whether the log has been used.
-
-
Method Detail
-
reset
protected void reset()
Resets the handler.
-
initialize
protected void initialize()
Initializes the members.
-
setUp
protected void setUp()
Hook method for performing setup before processing first log record.
-
doPublish
protected abstract 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.
- Parameters:
record
- description of the log event. A null record is silently ignored and is not published
-
postPublish
protected void postPublish(LogRecord record)
Hook method after logging occurred.- Parameters:
record
- description of the log event. A null record is silently ignored and is not published
-
publish
public void publish(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.
-
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.
- Specified by:
close
in classHandler
- Throws:
SecurityException
- if a security manager exists and if the caller does not have LoggingPermission("control").
-
addLoggingListener
public void addLoggingListener(LoggingListener l)
Adds the specified logging listener.- Parameters:
l
- the listener to add
-
removeLoggingListener
public void removeLoggingListener(LoggingListener l)
Removes the specified logging listener.- Parameters:
l
- the listener to remove
-
removeLoggingListeners
public void removeLoggingListeners()
Removes all logging listener.
-
iterator
public Iterator<LoggingListener> iterator()
Returns an iterator over all current logging listeners.- Returns:
- the iterator
-
loggingListeners
public Set<LoggingListener> loggingListeners()
Returns an iterator over all current logging listeners.- Returns:
- the iterator
-
notifyLoggingListeners
protected void notifyLoggingListeners(LogRecord record)
Sends out the log record to its listeners.- Parameters:
record
- the record to broadcast
-
compareTo
public int compareTo(Handler o)
Compares the handler with itself.- Specified by:
compareTo
in interfaceComparable<Handler>
- 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
-
equals
public boolean equals(Object obj)
Checks whether the provided object is the same as this handler.- Overrides:
equals
in classObject
- Parameters:
obj
- the object to check- Returns:
- true if the same
- See Also:
compareTo(Handler)
-
-