Class GenericLog
java.lang.Object
com.mcpdbwizard.pub.GenericLog
- All Implemented Interfaces:
LogInterface
- Direct Known Subclasses:
ConsoleLog,JulLog,Log4j2Log,Slf4jLog,TextLog
Partial implementation of LogInterface that composes error messages but leaves the actual
logging to other classes.
See LogInterface
(c) Copyright 2004-2026 ATB Consultancy Services Ltd (formerly Orinda Software Ltd, Dublin, Ireland)
- Version:
- 5.0
- Author:
- ATB Consultancy Services Ltd
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanFlag to indicate whether we should call theflush()method every time we print a message.protected booleanFlag to indicate whether messages should be logged by default.protected static booleanFlag to indicate whether we are printing debug messages.protected static final String"Log file being flushed" messageprotected booleanFlag to indicate whether we should include the Thread id every time we print a message.Fields 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 TypeMethodDescriptionvoidLog a debug message.voidLog a debug message.voiddebugOff()Turn debug messages offvoiddebugOn()Turn debug messages onvoidLog an Exception.voidLog an error message.voidLog an error message.voidLog an error message.abstract voidflush()If the log is buffered then flush any outstanding changes.protected StringformatMessage(String messageType, String messageText) Format a message and return it as a printable stringabstract StringReturns a string with the name of the current log.Return date format stringbooleangetDebug()Get debug statusvoidLog an informational message.voidLog an informational message.voidsetAutoFlush(boolean flushEveryMessage) Controls whether the class should flush the log every time it is asked to print a message.voidsetAutoLog(boolean logEveryMessageByDefault) Controls whether the class should log every message unless told not to.voidLog a serious Exception.voidLog a serious Exception.voidLog a serious error message.voidLog a serious error message.voidLog a warning message.voidLog a warning message.protected abstract voidwriteMessage(String messageType, String messageText, boolean isModal, boolean isLogged) Format a message and write it to whatever it is we are writing to.
-
Field Details
-
LOG_BEING_FLUSHED
-
debugMessagesPrinted
protected static boolean debugMessagesPrintedFlag to indicate whether we are printing debug messages. Defaults tofalse. -
autoLog
protected boolean autoLogFlag to indicate whether messages should be logged by default. Defaults totrue. -
autoFlush
protected boolean autoFlushFlag to indicate whether we should call theflush()method every time we print a message. Defaults tofalse.- See Also:
-
printThreadId
protected boolean printThreadIdFlag to indicate whether we should include the Thread id every time we print a message. Defaults tofalse.
-
-
Constructor Details
-
GenericLog
public GenericLog()Create an instance of GenericLog.
-
-
Method Details
-
getDateFormat
Return date format string- Specified by:
getDateFormatin interfaceLogInterface- Returns:
- The Date format
-
debugOn
-
debugOff
-
getDebug
public boolean getDebug()Get debug status- Specified by:
getDebugin interfaceLogInterface- Returns:
trueif debug messages are being printed.
-
debug
Description copied from interface:LogInterfaceLog a debug message. The user does not have to see it. It will always be logged.- Specified by:
debugin interfaceLogInterface- Parameters:
theMessage- A string containing the message.
-
debug
Description copied from interface:LogInterfaceLog a debug message. The user may be forced to acknowledge it. It may be logged. Debug messages are off by default.- Specified by:
debugin interfaceLogInterface- Parameters:
theMessage- A string containing the message.isModal-trueif the user must be forced to acknowlege this message. Only meaningful if a GUI is in use.isLogged-trueif this message is to be stored somewhere.
-
info
Description copied from interface:LogInterfaceLog an informational message. The user does not have to acknowlege it. It will not be logged.- Specified by:
infoin interfaceLogInterface- Parameters:
theMessage- A string containing the message.
-
info
Description copied from interface:LogInterfaceLog an informational message. The user may be forced to acknowledge it. It may be logged.- Specified by:
infoin interfaceLogInterface- Parameters:
theMessage- A string containing the message.isModal-trueif the user must be forced to acknowlege this message. Only meaningful if a GUI is in use.isLogged-trueif this message is to be stored somewhere.
-
warning
Description copied from interface:LogInterfaceLog a warning message. The user does not have to acknowlege it. It will not be logged.- Specified by:
warningin interfaceLogInterface- Parameters:
theMessage- A string containing the message.
-
warning
Description copied from interface:LogInterfaceLog a warning message. The user may be forced to acknowledge it. It may be logged.- Specified by:
warningin interfaceLogInterface- Parameters:
theMessage- A string containing the message.isModal-trueif the user must be forced to acknowlege this message. Only meaningful if a GUI is in use.isLogged-trueif this message is to be stored somewhere.
-
error
Description copied from interface:LogInterfaceLog an error message. The user does not have to acknowlege it. It will not be logged.- Specified by:
errorin interfaceLogInterface- Parameters:
theMessage- A string containing the message.
-
error
Description copied from interface:LogInterfaceLog an error message. The user may be forced to acknowledge it. It may be logged.- Specified by:
errorin interfaceLogInterface- Parameters:
theMessage- A string containing the message.isModal-trueif the user must be forced to acknowlege this message. Only meaningful if a GUI is in use.isLogged-trueif this message is to be stored somewhere.
-
error
Description copied from interface:LogInterfaceLog an Exception. The user does not have to acknowlege it. It will not be logged.- Specified by:
errorin interfaceLogInterface- Parameters:
theException- A string containing the message.
-
error
Description copied from interface:LogInterfaceLog an error message. The user may be forced to acknowledge it. It may be logged.- Specified by:
errorin interfaceLogInterface- Parameters:
theException- A string containing the message.isModal-trueif the user must be forced to acknowlege this message. Only meaningful if a GUI is in use.isLogged-trueif this message is to be stored somewhere.
-
syserror
Description copied from interface:LogInterfaceLog a serious error message. The user does not have to acknowlege it. It will not be logged.- Specified by:
syserrorin interfaceLogInterface- Parameters:
theMessage- A string containing the message.
-
syserror
Description copied from interface:LogInterfaceLog a serious error message. The user may be forced to acknowledge it. It may be logged.- Specified by:
syserrorin interfaceLogInterface- Parameters:
theMessage- A string containing the message.isModal-trueif the user must be forced to acknowlege this message. Only meaningful if a GUI is in use.isLogged-trueif this message is to be stored somewhere.
-
syserror
Description copied from interface:LogInterfaceLog a serious Exception. The user does not have to acknowlege it. It will not be logged.- Specified by:
syserrorin interfaceLogInterface- Parameters:
theException- A string containing the message.
-
syserror
Description copied from interface:LogInterfaceLog a serious Exception. The user may be forced to acknowledge it. It may be logged.- Specified by:
syserrorin interfaceLogInterface- Parameters:
theException- A string containing the message.isModal-trueif the user must be forced to acknowlege this message. Only meaningful if a GUI is in use.isLogged-trueif this message is to be stored somewhere.
-
flush
public abstract void flush()Description copied from interface:LogInterfaceIf the log is buffered then flush any outstanding changes. If the log is not buffered do nothing.- Specified by:
flushin interfaceLogInterface
-
getCurrentLog
Description copied from interface:LogInterfaceReturns a string with the name of the current log.- Specified by:
getCurrentLogin interfaceLogInterface- Returns:
- A full path name if a conventional log file is in use, or a descriptive string if no log file is in use.
-
formatMessage
Format a message and return it as a printable string- Parameters:
messageType- should be one of the constants DEBUG, INFO, WARN, ERROR or SYSERR as defined in LogInterface.messageText- The message- Returns:
- String a formatted message
-
setAutoLog
public void setAutoLog(boolean logEveryMessageByDefault) Controls whether the class should log every message unless told not to.- Specified by:
setAutoLogin interfaceLogInterface- Parameters:
logEveryMessageByDefault-trueif messages are to be logged by default.
-
setAutoFlush
public void setAutoFlush(boolean flushEveryMessage) Controls whether the class should flush the log every time it is asked to print a message. Slower but more reliable.- Specified by:
setAutoFlushin interfaceLogInterface- Parameters:
flushEveryMessage-trueif the log is to be flushed every time a message is written to it.
-
writeMessage
protected abstract void writeMessage(String messageType, String messageText, boolean isModal, boolean isLogged) Format a message and write it to whatever it is we are writing to.- Parameters:
messageType- should be one of the constants DEBUG, INFO, WARN, ERROR or SYSERR as defined in LogInterface.messageText- The message
-