Class MetaDebugUtil
- java.lang.Object
 - 
- edu.uiuc.ncsa.security.core.util.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
 
 
- 
- 
Field Summary
Fields Modifier and Type Field Description protected intdebugLevelstatic StringDEFAULT_TITLEStringhoststatic StringJSON_DELIMITERstatic StringJSON_ENABLEDstatic StringJSON_HOSTstatic StringJSON_LEVELstatic StringJSON_TITLEstatic StringJSON_TS_ON- 
Fields inherited from interface edu.uiuc.ncsa.security.core.util.DebugConstants
DEBUG_LEVEL_ERROR, DEBUG_LEVEL_ERROR_LABEL, DEBUG_LEVEL_INFO, DEBUG_LEVEL_INFO_LABEL, DEBUG_LEVEL_OFF, DEBUG_LEVEL_OFF_LABEL, DEBUG_LEVEL_SEVERE, DEBUG_LEVEL_SEVERE_LABEL, DEBUG_LEVEL_TRACE, DEBUG_LEVEL_TRACE_LABEL, DEBUG_LEVEL_UNKNOWN, DEBUG_LEVEL_WARN, DEBUG_LEVEL_WARN_LABEL 
 - 
 
- 
Constructor Summary
Constructors Constructor Description MetaDebugUtil()MetaDebugUtil(String title, int debugLevel, boolean printTS)MetaDebugUtil(String title, int debugLevel, boolean printTS, String host) 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected static booleancheckLevelAndLabel(String targetLabel, String givenLabel)Do a case-insensitive check for equality of a given label and one of the pre-defined (target) labels.voiderror(Class callingClass, String message)voiderror(Class callingClass, String message, Throwable t)voiderror(Object obj, String message)voiderror(Object obj, String message, Throwable t)voiderror(String message)voiderror(String title, String message)voiderror(String title, String message, Throwable t)voiderror(String message, Throwable t)voidfromJSON(net.sf.json.JSONObject json)intgetDebugLevel()StringgetDelimiter()StringgetHost()StringgetTitle()Name of the component that goes in the entry.booleanhasHost()voidinfo(Class callingClass, String message)voidinfo(Object obj, String message)voidinfo(String message)voidinfo(String title, String message)booleanisEnabled()Checks if the debug level is set to off.booleanisPrintTS()voidprintIt(int level, Class callingClass, String message)voidprintIt(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.voidprintIt(int level, String title, String message)voidprintIt(int level, String title, String message, Throwable throwable)protected voidprintIt(String message)voidsetDebugLevel(int newDebugLevel)voidsetDebugLevel(String label)This is used to set the debugging level from a label.voidsetDelimiter(String delimiter)voidsetHost(String host)voidsetIsEnabled(boolean isEnabled)Deprecated.voidsetPrintTS(boolean printTS)voidsetTitle(String title)voidsevere(Class callingClass, String message)voidsevere(Class callingClass, String message, Throwable t)voidsevere(Object obj, String message)voidsevere(Object obj, String message, Throwable t)voidsevere(String message)voidsevere(String title, String message)voidsevere(String title, String message, Throwable t)voidsevere(String message, Throwable t)net.sf.json.JSONObjecttoJSON()static StringtoLabel(int level)static inttoLevel(String label)StringtoString()voidtrace(Class callingClass, String message)voidtrace(Class callingClass, String message, Throwable t)voidtrace(Object obj, String message)voidtrace(Object obj, String message, Throwable t)voidtrace(String message)voidtrace(String title, String message)voidtrace(String title, String message, Throwable t)voidtrace(String message, Throwable t)voidwarn(Class callingClass, String message)voidwarn(Object obj, String message)voidwarn(String message)voidwarn(String title, String message) 
 - 
 
- 
- 
Field Detail
- 
DEFAULT_TITLE
public static String DEFAULT_TITLE
 
- 
debugLevel
protected int debugLevel
 
- 
host
public String host
 
- 
JSON_LEVEL
public static final String JSON_LEVEL
- See Also:
 - Constant Field Values
 
 
- 
JSON_DELIMITER
public static final String JSON_DELIMITER
- See Also:
 - Constant Field Values
 
 
- 
JSON_TS_ON
public static final String JSON_TS_ON
- See Also:
 - Constant Field Values
 
 
- 
JSON_TITLE
public static final String JSON_TITLE
- See Also:
 - Constant Field Values
 
 
- 
JSON_ENABLED
public static final String JSON_ENABLED
- See Also:
 - Constant Field Values
 
 
- 
JSON_HOST
public static final String JSON_HOST
- See Also:
 - Constant Field Values
 
 
 - 
 
- 
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 thesetDebugLevel(int)directly. Some very old applications still use this.- Parameters:
 isEnabled-
 
- 
getDelimiter
public String getDelimiter()
 
- 
setDelimiter
public void setDelimiter(String delimiter)
 
- 
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)
 
- 
warn
public void warn(String message)
 
- 
error
public void error(String message)
 
- 
severe
public void severe(String message)
 
- 
trace
public void trace(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)
 
 - 
 
 -