Class TextLog
java.lang.Object
com.mcpdbwizard.pub.GenericLog
com.mcpdbwizard.pub.TextLog
- All Implemented Interfaces:
LogInterface,AutoCloseable
- Direct Known Subclasses:
UiLog
A heavyweight implementation of
LogInterface.
TextLog is a logging mechanism designed for large volumes of data over a protracted period of time. Log files are stored in their own dedicated directory structure.
See LogInterface
Copyright 2003-2026 ATB Consultancy Services Ltd (formerly Orinda Software Ltd, Dublin, Ireland)
- Version:
- 7
- Author:
- [email protected]
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanWhether messages are to be printed in standard output/error as well as written to a log fileprotected intHow many messages are in this log file.protected booleanA flag that is set if we can't write any moreprotected static final StringFile extension for log files.protected SimpleDateFormatThe Year/Month/Day format in useprotected SimpleDateFormatThe Hour/Minute format in useprotected static final intMax number of messages in a log file.protected FileThe current log fileprotected FileThe directory log files will be kept in.protected StringA mnemonic prefix used for naming the log filesFields inherited from class com.mcpdbwizard.pub.GenericLog
autoFlush, autoLog, debugMessagesPrinted, LOG_BEING_FLUSHED, printThreadIdFields inherited from interface com.mcpdbwizard.pub.LogInterface
DEBUG, DEFAULT_FIELD_DELIMITER, DEFAULT_FILENAME_DAY_FORMAT, DEFAULT_FILENAME_TIME_FORMAT, DEFAULT_TIME_FORMAT_STRING, ERROR, INFO, SYSERR, WARN -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close log file if currently open.voidFlush and close the current log file.voidflush()Flush any outstanding changes.booleanFind out whether messages are being sent to standard output and standard error.Get current log file name.protected Stringfigure out what the date part of the log file should be calledprotected StringgetLogFileName(String thePrefix, String fileExtension) Return a new log file name.protected Stringfigure out what the time part of the log file should be calledvoidsetConsoleOutput(boolean sendOutputToConsole) Set whether messages are to be sent to standard output and standard error.protected voidwriteMessage(String messageType, String messageText, boolean isModal, boolean isLogged) Format a message and log it to the current log file.Methods inherited from class com.mcpdbwizard.pub.GenericLog
debug, debug, debugOff, debugOn, error, error, error, error, formatMessage, getDateFormat, getDebug, info, info, setAutoFlush, setAutoLog, syserror, syserror, syserror, syserror, warning, warning
-
Field Details
-
MAX_MESSAGES_PER_FILE
protected static final int MAX_MESSAGES_PER_FILEMax number of messages in a log file.Once this limit is reached the log file will switch.
- See Also:
-
LOG_FILE_EXTENSION
-
howManyMessagesInThisFile
protected int howManyMessagesInThisFileHow many messages are in this log file. -
thePrefix
A mnemonic prefix used for naming the log files -
logFileDayFormat
The Year/Month/Day format in use -
logFileTimeFormat
The Hour/Minute format in use -
theDirectoryFile
The directory log files will be kept in. -
theCurrentLogFile
The current log file -
iAmBroken
protected boolean iAmBrokenA flag that is set if we can't write any more -
consoleOutput
protected boolean consoleOutputWhether messages are to be printed in standard output/error as well as written to a log file
-
-
Constructor Details
-
TextLog
Create an instance of TextLog. The log files will reside in the current working directory.- Parameters:
thePrefix- A mnemonic prefix used for naming the log file.
-
TextLog
-
-
Method Details
-
writeMessage
protected void writeMessage(String messageType, String messageText, boolean isModal, boolean isLogged) Format a message and log it to the current log file.- Specified by:
writeMessagein classGenericLog- Parameters:
messageType- should be one of the constants DEBUG, INFO, WARN, ERROR or SYSERR as defined in LogInterface.messageText- The messageisModal- ignored as we are dumping messages to a file.isLogged- whether the message is logged or not.
-
getLogFileDate
figure out what the date part of the log file should be called -
getLogFileTime
figure out what the time part of the log file should be called -
getLogFileName
-
closeFile
public void closeFile()Flush and close the current log file. -
flush
public void flush()Flush any outstanding changes.- Specified by:
flushin interfaceLogInterface- Specified by:
flushin classGenericLog
-
getCurrentLog
Get current log file name.- Specified by:
getCurrentLogin interfaceLogInterface- Specified by:
getCurrentLogin classGenericLog- Returns:
- An absolute file name if we are writing to a log file.
"NONE" If we haven't started writing to a file yet. Log files aren't opened until the first call to
writeMessage"BROKEN" If we were unable to open a log file.
-
getConsoleOutput
public boolean getConsoleOutput()Find out whether messages are being sent to standard output and standard error. -
setConsoleOutput
public void setConsoleOutput(boolean sendOutputToConsole) Set whether messages are to be sent to standard output and standard error. -
close
public void close()Close log file if currently open.- Specified by:
closein interfaceAutoCloseable
-