Package loci.common
Class DebugTools
java.lang.Object
loci.common.DebugTools
A utility class with convenience methods for debugging.
- Author:
- Curtis Rueden ctrueden at wisc.edu
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanenableIJLogging(boolean debug) Enable SLF4J logging using logback, in the context of ImageJ.static booleanAttempts to enable SLF4J logging via logback or log4j.static booleanenableLogging(String level) Attempts to enable SLF4J logging and set the root logger level.static StringgetFieldName(Class<?> c, int value) This method uses reflection to scan the values of the given class's static fields, returning the first matching field's name.static StringExtracts the given exception's corresponding stack trace to a string.static booleanChecks whether SLF4J logging has been enabled via logback or log4j.static voidsetRootLevel(String level) Sets the root logger level.
-
Method Details
-
getStackTrace
Extracts the given exception's corresponding stack trace to a string.- Parameters:
t- the Throwable from which to extract a stack trace- Returns:
- the complete stack trace as a String
-
isEnabled
public static boolean isEnabled()Checks whether SLF4J logging has been enabled via logback or log4j.- Returns:
trueif logging has been successfully enabled
-
setRootLevel
Sets the root logger level. This method will override the root logger level independently of the way the logging framework has been enabled.- Parameters:
level- A string indicating the desired level
-
enableLogging
public static boolean enableLogging()Attempts to enable SLF4J logging via logback or log4j. This will first check whether the logging has been enabled using the return value ofisEnabled().- Returns:
trueif logging was successfully enabled by this method
-
enableLogging
Attempts to enable SLF4J logging and set the root logger level. This method will first try to initialize the logging usingenableLogging(). If this method returnstrue, the root logger level is also set viasetRootLevel(String)using the input level.- Parameters:
level- A string indicating the desired level- Returns:
trueif logging was successfully enabled by this method
-
enableIJLogging
public static boolean enableIJLogging(boolean debug) Enable SLF4J logging using logback, in the context of ImageJ. This allows logging events to be echoed to the ImageJ status bar, regardless of how the logging configuration file was set up.- Parameters:
debug- true if debug-level output should be shown- Returns:
- whether or not ImageJ log enabling was successful
-
getFieldName
This method uses reflection to scan the values of the given class's static fields, returning the first matching field's name.- Parameters:
c- the class to scanvalue- the int value of the field to find- Returns:
- the name of the field, or the string representation of
valueif a matching field is not found
-