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 int
debugLevel
static String
DEFAULT_TITLE
String
host
static String
JSON_DELIMITER
static String
JSON_ENABLED
static String
JSON_HOST
static String
JSON_LEVEL
static String
JSON_TITLE
static String
JSON_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 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.void
error(Class callingClass, String message)
void
error(Class callingClass, String message, Throwable t)
void
error(Object obj, String message)
void
error(Object obj, String message, Throwable t)
void
error(String message)
void
error(String title, String message)
void
error(String title, String message, Throwable t)
void
error(String message, Throwable t)
void
fromJSON(net.sf.json.JSONObject json)
int
getDebugLevel()
String
getDelimiter()
String
getHost()
String
getTitle()
Name of the component that goes in the entry.boolean
hasHost()
void
info(Class callingClass, String message)
void
info(Object obj, String message)
void
info(String message)
void
info(String title, String message)
boolean
isEnabled()
Checks if the debug level is set to off.boolean
isPrintTS()
void
printIt(int level, Class callingClass, String message)
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.void
printIt(int level, String title, String message)
void
printIt(int level, String title, String message, Throwable throwable)
protected void
printIt(String message)
void
setDebugLevel(int newDebugLevel)
void
setDebugLevel(String label)
This is used to set the debugging level from a label.void
setDelimiter(String delimiter)
void
setHost(String host)
void
setIsEnabled(boolean isEnabled)
Deprecated.void
setPrintTS(boolean printTS)
void
setTitle(String title)
void
severe(Class callingClass, String message)
void
severe(Class callingClass, String message, Throwable t)
void
severe(Object obj, String message)
void
severe(Object obj, String message, Throwable t)
void
severe(String message)
void
severe(String title, String message)
void
severe(String title, String message, Throwable t)
void
severe(String message, Throwable t)
net.sf.json.JSONObject
toJSON()
static String
toLabel(int level)
static int
toLevel(String label)
String
toString()
void
trace(Class callingClass, String message)
void
trace(Class callingClass, String message, Throwable t)
void
trace(Object obj, String message)
void
trace(Object obj, String message, Throwable t)
void
trace(String message)
void
trace(String title, String message)
void
trace(String title, String message, Throwable t)
void
trace(String message, Throwable t)
void
warn(Class callingClass, String message)
void
warn(Object obj, String message)
void
warn(String message)
void
warn(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)
-
-