Class DebugUtil

  • All Implemented Interfaces:
    DebugConstants
    Direct Known Subclasses:
    ServletDebugUtil

    public class DebugUtil
    extends Object
    implements DebugConstants
    Utilities for centralizing some common debugging commands. The debug level is set globally for all calls to this. Note that this is not logging. Use the MyLoggingFacade for that. This is for levels of debugging that may be turned off completely. Logging will be put into the log file. Debugging commands all go to stderr so that they are not part of logging on purpose, but can be collected and viewed separately.

    Optionally if this is being run on a server, you may specify a host to be printed with each message. If this is not set, that is fine.

    Created by Jeff Gaynor
    on 7/27/16 at 2:55 PM

    • Field Detail

      • NCSA_DEV_INPUT

        public static String NCSA_DEV_INPUT
      • DEFAULT_DEV_ROOT

        public static String DEFAULT_DEV_ROOT
      • NCSA_CONFIG_ROOT

        public static String NCSA_CONFIG_ROOT
      • DEFAULT_CONFIG_ROOT

        public static String DEFAULT_CONFIG_ROOT
      • NCSA_DEV_OUTPUT

        public static String NCSA_DEV_OUTPUT
      • DEFAULT_DEV_OUTPUT

        public static String DEFAULT_DEV_OUTPUT
    • Constructor Detail

      • DebugUtil

        public DebugUtil()
    • Method Detail

      • setInstance

        public static void setInstance​(MetaDebugUtil newDebugUtil)
      • hasInstance

        public static boolean hasInstance()
        If an instance has been set. Note that calling getInstance() will always return an instance.
        Returns:
      • setEnabled

        public static void setEnabled​(boolean enabled)
      • isPrintTS

        public static boolean isPrintTS()
      • setPrintTS

        public static void setPrintTS​(boolean printTS)
      • toLabel

        protected static String toLabel​(int level)
      • setDebugLevel

        public static void setDebugLevel​(String label)
        This is used to set the debugging level from a label.
        Parameters:
        label -
      • toLevel

        protected static int toLevel​(String label)
      • getDebugLevel

        public static int getDebugLevel()
      • setDebugLevel

        public static void setDebugLevel​(int newDebugLevel)
      • isEnabled

        public static boolean isEnabled()
      • printStackTrace

        public static void printStackTrace​(Throwable t)
      • setIsEnabled

        public static void setIsEnabled​(boolean isEnabled)
      • printIt

        public static void printIt​(int level,
                                   Class callingClass,
                                   String message)
      • printIt

        protected static void printIt​(String message)
      • printIt

        public static void printIt​(int level,
                                   Class callingClass,
                                   String message,
                                   Throwable throwable)
        This only prints if the requested level is at least error AND the current utility supports it. Note that if there is no exception, then that is noted in the log as well.
        Parameters:
        level -
        callingClass -
        message -
        throwable -
      • info

        public static void info​(String message)
      • info

        public static void info​(String title,
                                String message)
      • info

        public static void info​(Class callingClass,
                                String message)
      • info

        public static void info​(Object obj,
                                String message)
      • warn

        public static void warn​(String message)
      • warn

        public static void warn​(String title,
                                String message)
      • warn

        public static void warn​(Class callingClass,
                                String message)
      • warn

        public static void warn​(Object obj,
                                String message)
      • error

        public static void error​(Class callingClass,
                                 String message)
      • error

        public static void error​(Object obj,
                                 String message)
      • severe

        public static void severe​(Class callingClass,
                                  String message)
      • severe

        public static void severe​(Object obj,
                                  String message)
      • trace

        public static void trace​(String message)
      • trace

        public static void trace​(Class callingClass,
                                 String message)
      • trace

        public static void trace​(Object obj,
                                 String message)
      • trace

        public static void trace​(boolean doLocal,
                                 Class callingClass,
                                 String message,
                                 Throwable t)
      • trace

        public static void trace​(boolean doLocal,
                                 Class callingClass,
                                 String message)
      • trace

        public static void trace​(boolean doLocal,
                                 Object obj,
                                 String message)
      • dbg

        public static void dbg​(Object callingObject,
                               String message)
        Deprecated.
        use warn instead
        This will print out a message from a class that includes the class name and current timestamp.
        Parameters:
        callingObject -
        message -
      • dbg

        public static void dbg​(Object callingObject,
                               String message,
                               Throwable throwable)
        Deprecated.
        use error instead
        Parameters:
        callingObject -
        message -
        throwable -
      • dbg

        public static void dbg​(Class callingClass,
                               String message,
                               Throwable throwable)
        Deprecated.
        use error instead
        Parameters:
        callingClass -
        message -
        throwable -
      • dbg

        public static void dbg​(Class callingClass,
                               String message)
        Deprecated.
        use warn instead
        Parameters:
        callingClass -
        message -
      • setHost

        public static void setHost​(String host)
      • getDevPath

        public static String getDevPath()
        This is used to supply all the paths in tests. Set the environment variable NCSA_DEV_PATH and it will be used to resolve resources etc.
        Returns:
      • getConfigPath

        public static String getConfigPath()
      • getDevOutput

        public static String getDevOutput()