Class MetaDebugUtil

  • All Implemented Interfaces:
    DebugConstants, Serializable

    public class MetaDebugUtil
    extends Object
    implements DebugConstants, Serializable

    Very useful debugging class. This is much like logging with various levels of debugging available, but this prints to std err, not std out. The idea is that you can stick debug notices everywhere and turn it off and on as needed. Giving a second debug-only system that is not loggged. In many cases you do not want debug information going to a log (such as if the log might be public and there is sensitive information). This lets you stick view it separately.

    What other advantage to a debug system? In many cases code is running in some service that has logging, say, piped to the system log. (Common approach for Tomcat running under Apache). This means that the log might be simply enormous and processing it looking for your 3 debug statements is hard or very slow. (Think active production server with literally hundreds of entries being generated every second.) These debug statements get sent to standard error, so it is easy to turn it on for a bit, pick them up, then turn debugging back off.

    Created by Jeff Gaynor
    on 10/23/20 at 2:54 PM

    See Also:
    Serialized Form
    • Constructor Detail

      • MetaDebugUtil

        public MetaDebugUtil()
      • MetaDebugUtil

        public MetaDebugUtil​(String title,
                             int debugLevel,
                             boolean printTS,
                             String host)
      • MetaDebugUtil

        public MetaDebugUtil​(String title,
                             int debugLevel,
                             boolean printTS)
    • Method Detail

      • isPrintTS

        public boolean isPrintTS()
      • setPrintTS

        public void setPrintTS​(boolean printTS)
      • getTitle

        public String getTitle()
        Name of the component that goes in the entry. This may be set and used implcitly or you may explicitly call with the name of the object.
        Returns:
      • setTitle

        public void setTitle​(String title)
      • toLabel

        public static String toLabel​(int level)
      • checkLevelAndLabel

        protected static boolean checkLevelAndLabel​(String targetLabel,
                                                    String givenLabel)
        Do a case-insensitive check for equality of a given label and one of the pre-defined (target) labels.
        Parameters:
        targetLabel -
        givenLabel -
        Returns:
      • setDebugLevel

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

        public static int toLevel​(String label)
      • getDebugLevel

        public int getDebugLevel()
      • setDebugLevel

        public void setDebugLevel​(int newDebugLevel)
      • isEnabled

        public boolean isEnabled()
        Checks if the debug level is set to off.
        Returns:
      • setIsEnabled

        public void setIsEnabled​(boolean isEnabled)
        Deprecated.
        Setting this to true will set the debug level to warn only. It is better to use the setDebugLevel(int) directly. Some very old applications still use this.
        Parameters:
        isEnabled -
      • getDelimiter

        public String getDelimiter()
      • setDelimiter

        public void setDelimiter​(String delimiter)
      • printIt

        public void printIt​(int level,
                            String title,
                            String message)
      • printIt

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

        protected void printIt​(String message)
      • printIt

        public 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 void info​(String message)
      • info

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

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

        public void warn​(String message)
      • warn

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

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

        public void error​(String message)
      • error

        public void error​(String title,
                          String message)
      • error

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

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

        public void severe​(String message)
      • severe

        public void severe​(String title,
                           String message)
      • severe

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

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

        public void trace​(String message)
      • trace

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

        public void trace​(String title,
                          String message)
      • trace

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

        public boolean hasHost()
      • getHost

        public String getHost()
      • setHost

        public void setHost​(String host)
      • toJSON

        public net.sf.json.JSONObject toJSON()
      • fromJSON

        public void fromJSON​(net.sf.json.JSONObject json)