public final class DebugScope extends Object implements Debug.Scope
Modifier and Type | Class and Description |
---|---|
private class |
DebugScope.IndentImpl |
Modifier and Type | Field and Description |
---|---|
private static ThreadLocal<DebugConfig> |
configTL |
private Object[] |
context |
private int |
currentDumpLevel |
private int |
currentLogLevel |
(package private) static Object[] |
EMPTY_CONTEXT |
private static ThreadLocal<DebugScope> |
instanceTL |
private static ThreadLocal<DebugScope> |
lastClosedTL |
private static ThreadLocal<Throwable> |
lastExceptionThrownTL |
private DebugScope.IndentImpl |
lastUsedIndent |
private boolean |
logScopeName |
private boolean |
memUseTrackingEnabled |
private boolean |
meterEnabled |
private PrintStream |
output |
private DebugScope |
parent |
private DebugConfig |
parentConfig |
private String |
qualifiedName |
private boolean |
sandbox |
private static char |
SCOPE_SEP |
private boolean |
timeEnabled |
private String |
unqualifiedName |
private DebugValueMap |
valueMap |
private boolean |
verifyEnabled |
Modifier | Constructor and Description |
---|---|
private |
DebugScope(String unqualifiedName,
DebugScope parent,
boolean sandbox,
Object... context) |
private |
DebugScope(Thread thread) |
Modifier and Type | Method and Description |
---|---|
static <T> T |
call(Callable<T> callable) |
void |
close() |
private void |
computeValueMap(String name) |
private DebugScope |
createChild(String newName,
Object[] newContext) |
void |
dump(int dumpLevel,
Object object,
String formatString,
Object... args) |
private static TopLevelDebugConfig |
fetchTopLevelDebugConfig(String msg) |
static void |
forceDump(Object object,
String format,
Object... args)
This method exists mainly to allow a debugger (e.g., Eclipse) to force dump a graph.
|
static DebugConfig |
getConfig() |
Iterable<Object> |
getCurrentContext() |
(package private) long |
getCurrentValue(int index) |
static DebugScope |
getInstance() |
DebugScope.IndentImpl |
getLastUsedIndent() |
String |
getQualifiedName() |
private DebugValueMap |
getValueMap() |
RuntimeException |
handle(Throwable e) |
private RuntimeException |
interceptException(Throwable e) |
boolean |
isDumpEnabled(int dumpLevel) |
boolean |
isLogEnabled(int logLevel) |
boolean |
isMemUseTrackingEnabled() |
boolean |
isMeterEnabled() |
boolean |
isTimeEnabled() |
boolean |
isVerifyEnabled() |
void |
log(int logLevel,
String msg,
Object... args) |
Indent |
pushIndentLogger() |
private static void |
recursiveUpdateFlags() |
DebugScope |
scope(CharSequence name,
DebugConfig sandboxConfig,
Object... newContextObjects)
Creates and enters a new debug scope which is either a child of the current scope or a
disjoint top level scope.
|
void |
setConfig(DebugConfig newConfig) |
(package private) void |
setCurrentValue(int index,
long l) |
static void |
setDumpLevel(int dumpLevel)
Enable dumping at the new
dumpLevel for the remainder of enclosing scopes. |
static void |
setLogLevel(int logLevel)
Enable logging at the new
logLevel for the remainder of enclosing scopes. |
private void |
updateFlags() |
void |
verify(Object object,
String formatString,
Object... args) |
private static final ThreadLocal<DebugScope> instanceTL
private static final ThreadLocal<DebugScope> lastClosedTL
private static final ThreadLocal<DebugConfig> configTL
private static final ThreadLocal<Throwable> lastExceptionThrownTL
private final DebugScope parent
private final DebugConfig parentConfig
private final boolean sandbox
private DebugScope.IndentImpl lastUsedIndent
private boolean logScopeName
private DebugValueMap valueMap
private String qualifiedName
private final String unqualifiedName
private static final char SCOPE_SEP
private boolean meterEnabled
private boolean timeEnabled
private boolean memUseTrackingEnabled
private boolean verifyEnabled
private int currentDumpLevel
private int currentLogLevel
private PrintStream output
static final Object[] EMPTY_CONTEXT
private DebugScope(Thread thread)
private DebugScope(String unqualifiedName, DebugScope parent, boolean sandbox, Object... context)
public static DebugScope getInstance()
public static DebugConfig getConfig()
private void computeValueMap(String name)
public void close()
close
in interface Debug.Scope
close
in interface AutoCloseable
public boolean isDumpEnabled(int dumpLevel)
public static void setDumpLevel(int dumpLevel)
dumpLevel
for the remainder of enclosing scopes. This only
works if a TopLevelDebugConfig
was installed at a higher scope.dumpLevel
- public static void setLogLevel(int logLevel)
logLevel
for the remainder of enclosing scopes. This only
works if a TopLevelDebugConfig
was installed at a higher scope.logLevel
- private static void recursiveUpdateFlags()
private static TopLevelDebugConfig fetchTopLevelDebugConfig(String msg)
public boolean isVerifyEnabled()
public boolean isLogEnabled(int logLevel)
public boolean isMeterEnabled()
public boolean isTimeEnabled()
public boolean isMemUseTrackingEnabled()
public static void forceDump(Object object, String format, Object... args)
public void verify(Object object, String formatString, Object... args)
Debug.verify(Object, String)
public DebugScope scope(CharSequence name, DebugConfig sandboxConfig, Object... newContextObjects)
name
- the name of the new scopesandboxConfig
- the configuration to use for a new top level scope, or null if the new
scope should be a child scopenewContextObjects
- objects to be appended to the debug contextclose()
method is calledpublic RuntimeException handle(Throwable e)
private void updateFlags()
private RuntimeException interceptException(Throwable e)
private DebugValueMap getValueMap()
long getCurrentValue(int index)
void setCurrentValue(int index, long l)
private DebugScope createChild(String newName, Object[] newContext)
public Iterable<Object> getCurrentContext()
public void setConfig(DebugConfig newConfig)
public String getQualifiedName()
public Indent pushIndentLogger()
public DebugScope.IndentImpl getLastUsedIndent()