Class DebugLogger


  • public class DebugLogger
    extends java.lang.Object
    A small class to make debug logging easier. If debug is set to true, messages logged using log(String) will be logged via logger, else the message will just be ignored.
    • Constructor Summary

      Constructors 
      Constructor Description
      DebugLogger​(java.util.logging.Logger logger)
      Creates a DebugLogger using logger as the internal Logger.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getPrefix()
      Get the prefix to be prepended to the debug message.
      boolean isDebug()
      Get whether attempted debug logs will be logged via logger.
      void log​(java.lang.String message)
      Logs a message using logger if debug is true.
      void log​(java.lang.String message, java.lang.Object... formats)
      Convenience method which applies String.format(String, Object...) onto a message before passing it to log(String).
      void setDebug​(boolean debug)
      Set whether attempted debug logs will be logged via logger.
      void setPrefix​(java.lang.String prefix)
      Set the prefix to be prepended to the debug message.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DebugLogger

        public DebugLogger​(java.util.logging.Logger logger)
        Creates a DebugLogger using logger as the internal Logger.
        Parameters:
        logger - the Logger to be used when debugging is enabled.
    • Method Detail

      • isDebug

        public boolean isDebug()
        Get whether attempted debug logs will be logged via logger.
        Returns:
        whether debug is enabled or not
      • setDebug

        public void setDebug​(boolean debug)
        Set whether attempted debug logs will be logged via logger.
        Parameters:
        debug - whether debug should be enabled or not
      • getPrefix

        public java.lang.String getPrefix()
        Get the prefix to be prepended to the debug message.
        Returns:
        the prefix
      • setPrefix

        public void setPrefix​(java.lang.String prefix)
        Set the prefix to be prepended to the debug message.
        Parameters:
        prefix - the prefix
      • log

        public void log​(java.lang.String message)
        Logs a message using logger if debug is true.
        Parameters:
        message - the message to log
      • log

        public void log​(java.lang.String message,
                        java.lang.Object... formats)
        Convenience method which applies String.format(String, Object...) onto a message before passing it to log(String).
        Parameters:
        message - the message to log
        formats - formats to apply to the message