Class GenericLog

java.lang.Object
com.mcpdbwizard.pub.GenericLog
All Implemented Interfaces:
LogInterface
Direct Known Subclasses:
ConsoleLog, JulLog, Log4j2Log, Slf4jLog, TextLog

public abstract class GenericLog extends Object implements LogInterface
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 Details

    • LOG_BEING_FLUSHED

      protected static final String LOG_BEING_FLUSHED
      "Log file being flushed" message
      See Also:
    • debugMessagesPrinted

      protected static boolean debugMessagesPrinted
      Flag to indicate whether we are printing debug messages. Defaults to false.
    • autoLog

      protected boolean autoLog
      Flag to indicate whether messages should be logged by default. Defaults to true.
    • autoFlush

      protected boolean autoFlush
      Flag to indicate whether we should call the flush() method every time we print a message. Defaults to false.
      See Also:
    • printThreadId

      protected boolean printThreadId
      Flag to indicate whether we should include the Thread id every time we print a message. Defaults to false.
  • Constructor Details

    • GenericLog

      public GenericLog()
      Create an instance of GenericLog.
  • Method Details

    • getDateFormat

      public String getDateFormat()
      Return date format string
      Specified by:
      getDateFormat in interface LogInterface
      Returns:
      The Date format
    • debugOn

      public void debugOn()
      Turn debug messages on
      Specified by:
      debugOn in interface LogInterface
    • debugOff

      public void debugOff()
      Turn debug messages off
      Specified by:
      debugOff in interface LogInterface
    • getDebug

      public boolean getDebug()
      Get debug status
      Specified by:
      getDebug in interface LogInterface
      Returns:
      true if debug messages are being printed.
    • debug

      public void debug(String theMessage)
      Description copied from interface: LogInterface
      Log a debug message. The user does not have to see it. It will always be logged.
      Specified by:
      debug in interface LogInterface
      Parameters:
      theMessage - A string containing the message.
    • debug

      public void debug(String theMessage, boolean isModal, boolean isLogged)
      Description copied from interface: LogInterface
      Log a debug message. The user may be forced to acknowledge it. It may be logged. Debug messages are off by default.
      Specified by:
      debug in interface LogInterface
      Parameters:
      theMessage - A string containing the message.
      isModal - true if the user must be forced to acknowlege this message. Only meaningful if a GUI is in use.
      isLogged - true if this message is to be stored somewhere.
    • info

      public void info(String theMessage)
      Description copied from interface: LogInterface
      Log an informational message. The user does not have to acknowlege it. It will not be logged.
      Specified by:
      info in interface LogInterface
      Parameters:
      theMessage - A string containing the message.
    • info

      public void info(String theMessage, boolean isModal, boolean isLogged)
      Description copied from interface: LogInterface
      Log an informational message. The user may be forced to acknowledge it. It may be logged.
      Specified by:
      info in interface LogInterface
      Parameters:
      theMessage - A string containing the message.
      isModal - true if the user must be forced to acknowlege this message. Only meaningful if a GUI is in use.
      isLogged - true if this message is to be stored somewhere.
    • warning

      public void warning(String theMessage)
      Description copied from interface: LogInterface
      Log a warning message. The user does not have to acknowlege it. It will not be logged.
      Specified by:
      warning in interface LogInterface
      Parameters:
      theMessage - A string containing the message.
    • warning

      public void warning(String theMessage, boolean isModal, boolean isLogged)
      Description copied from interface: LogInterface
      Log a warning message. The user may be forced to acknowledge it. It may be logged.
      Specified by:
      warning in interface LogInterface
      Parameters:
      theMessage - A string containing the message.
      isModal - true if the user must be forced to acknowlege this message. Only meaningful if a GUI is in use.
      isLogged - true if this message is to be stored somewhere.
    • error

      public void error(String theMessage)
      Description copied from interface: LogInterface
      Log an error message. The user does not have to acknowlege it. It will not be logged.
      Specified by:
      error in interface LogInterface
      Parameters:
      theMessage - A string containing the message.
    • error

      public void error(String theMessage, boolean isModal, boolean isLogged)
      Description copied from interface: LogInterface
      Log an error message. The user may be forced to acknowledge it. It may be logged.
      Specified by:
      error in interface LogInterface
      Parameters:
      theMessage - A string containing the message.
      isModal - true if the user must be forced to acknowlege this message. Only meaningful if a GUI is in use.
      isLogged - true if this message is to be stored somewhere.
    • error

      public void error(Exception theException)
      Description copied from interface: LogInterface
      Log an Exception. The user does not have to acknowlege it. It will not be logged.
      Specified by:
      error in interface LogInterface
      Parameters:
      theException - A string containing the message.
    • error

      public void error(Exception theException, boolean isModal, boolean isLogged)
      Description copied from interface: LogInterface
      Log an error message. The user may be forced to acknowledge it. It may be logged.
      Specified by:
      error in interface LogInterface
      Parameters:
      theException - A string containing the message.
      isModal - true if the user must be forced to acknowlege this message. Only meaningful if a GUI is in use.
      isLogged - true if this message is to be stored somewhere.
    • syserror

      public void syserror(String theMessage)
      Description copied from interface: LogInterface
      Log a serious error message. The user does not have to acknowlege it. It will not be logged.
      Specified by:
      syserror in interface LogInterface
      Parameters:
      theMessage - A string containing the message.
    • syserror

      public void syserror(String theMessage, boolean isModal, boolean isLogged)
      Description copied from interface: LogInterface
      Log a serious error message. The user may be forced to acknowledge it. It may be logged.
      Specified by:
      syserror in interface LogInterface
      Parameters:
      theMessage - A string containing the message.
      isModal - true if the user must be forced to acknowlege this message. Only meaningful if a GUI is in use.
      isLogged - true if this message is to be stored somewhere.
    • syserror

      public void syserror(Exception theException)
      Description copied from interface: LogInterface
      Log a serious Exception. The user does not have to acknowlege it. It will not be logged.
      Specified by:
      syserror in interface LogInterface
      Parameters:
      theException - A string containing the message.
    • syserror

      public void syserror(Exception theException, boolean isModal, boolean isLogged)
      Description copied from interface: LogInterface
      Log a serious Exception. The user may be forced to acknowledge it. It may be logged.
      Specified by:
      syserror in interface LogInterface
      Parameters:
      theException - A string containing the message.
      isModal - true if the user must be forced to acknowlege this message. Only meaningful if a GUI is in use.
      isLogged - true if this message is to be stored somewhere.
    • flush

      public abstract void flush()
      Description copied from interface: LogInterface
      If the log is buffered then flush any outstanding changes. If the log is not buffered do nothing.
      Specified by:
      flush in interface LogInterface
    • getCurrentLog

      public abstract String getCurrentLog()
      Description copied from interface: LogInterface
      Returns a string with the name of the current log.
      Specified by:
      getCurrentLog in interface LogInterface
      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

      protected String formatMessage(String messageType, String messageText)
      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:
      setAutoLog in interface LogInterface
      Parameters:
      logEveryMessageByDefault - true if 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:
      setAutoFlush in interface LogInterface
      Parameters:
      flushEveryMessage - true if 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