Package adams.core.logging
Class FileHandler
- java.lang.Object
-
- java.util.logging.Handler
-
- adams.core.logging.AbstractLogHandler
-
- adams.core.logging.FileHandler
-
- All Implemented Interfaces:
Comparable<Handler>
- Direct Known Subclasses:
RotatingFileHandler
public class FileHandler extends AbstractLogHandler
Sends all logging output to the specified log file.
Makes use of the ADAMS_LOGFILE_PREFIX environment variable. E.g., with "ADAMS_LOGFILE_PREFIX=testing-", the default log file "$HOME/.adams/log/console.log" will become "$HOME/.adams/log/testing-console.log".- Author:
- fracpete (fracpete at waikato dot ac dot nz)
-
-
Field Summary
Fields Modifier and Type Field Description static String
ADAMS_LOGFILE_PREFIX
the environment variable to inject a prefix into the log file.protected File
m_LogFile
the log file to use.protected boolean
m_LogIsDir
whether the file points to a directory.-
Fields inherited from class adams.core.logging.AbstractLogHandler
m_LoggingListeners, m_LogUsed
-
-
Constructor Summary
Constructors Constructor Description FileHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(Handler o)
Compares the handler with itself.protected void
doPublish(LogRecord record)
Publish a LogRecord.File
getLogFile()
Returns the log file in use.protected void
initialize()
Initializes the members.void
setLogFile(File value)
Sets the log file to use.protected void
setUp()
Hook method for performing setup before processing first log record.-
Methods inherited from class adams.core.logging.AbstractLogHandler
addLoggingListener, close, equals, flush, iterator, loggingListeners, notifyLoggingListeners, postPublish, publish, removeLoggingListener, removeLoggingListeners, reset
-
Methods inherited from class java.util.logging.Handler
getEncoding, getErrorManager, getFilter, getFormatter, getLevel, isLoggable, reportError, setEncoding, setErrorManager, setFilter, setFormatter, setLevel
-
-
-
-
Field Detail
-
ADAMS_LOGFILE_PREFIX
public static final String ADAMS_LOGFILE_PREFIX
the environment variable to inject a prefix into the log file.- See Also:
- Constant Field Values
-
m_LogFile
protected File m_LogFile
the log file to use.
-
m_LogIsDir
protected boolean m_LogIsDir
whether the file points to a directory.
-
-
Method Detail
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initialize
in classAbstractLogHandler
-
setLogFile
public void setLogFile(File value)
Sets the log file to use.- Parameters:
value
- the file
-
getLogFile
public File getLogFile()
Returns the log file in use.- Returns:
- the file
-
setUp
protected void setUp()
Hook method for performing setup before processing first log record.- Overrides:
setUp
in classAbstractLogHandler
-
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
-
-