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 StringADAMS_LOGFILE_PREFIXthe environment variable to inject a prefix into the log file.protected static Map<File,Boolean>m_Configuredwhether the file has been configured.protected Filem_LogFilethe log file to use.protected booleanm_LogIsDirwhether 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 intcompareTo(Handler o)Compares the handler with itself.protected voiddoPublish(LogRecord record)Publish a LogRecord.FilegetLogFile()Returns the log file in use.protected voidinitialize()Initializes the members.protected booleanisSetUp()Returns whether the handler has been initialized.voidsetLogFile(File value)Sets the log file to use.protected voidsetUp()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_Configured
protected static final Map<File,Boolean> m_Configured
whether the file has been configured.
-
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:
initializein 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
-
isSetUp
protected boolean isSetUp()
Returns whether the handler has been initialized.- Overrides:
isSetUpin classAbstractLogHandler- Returns:
- true if initialized
-
setUp
protected void setUp()
Hook method for performing setup before processing first log record.- Overrides:
setUpin 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:
doPublishin 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:
compareToin interfaceComparable<Handler>- Overrides:
compareToin 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
-
-