public class StackDumper extends Object
If someone is printing "junk" to the console and you can't figure out why, try StackDumper.dumpWhenSysOutContains("junk")
.
Constructor and Description |
---|
StackDumper() |
Modifier and Type | Method and Description |
---|---|
static List<StackTraceElement> |
captureStackBelow(Class<?>... clazzes)
Captures all of the current stack which is below the given classes.
|
static void |
dump(String message)
Dumps the current stack to the system error console.
|
static void |
dump(String message,
int stackLimit,
String... classPrefixesToExclude)
Dumps the first
stackLimit frames of the current stack to the system error console, excluding traces from classPrefixesToExclude . |
static void |
dump(String message,
List<StackTraceElement> stack)
Dumps the given message and stack to the system error console.
|
static void |
dump(String message,
StackTraceElement[] stackTrace)
Dumps the given message and stack to the system error console.
|
static void |
dump(String message,
Throwable exception)
Dumps the given message and exception stack to the system error console
|
static void |
dumpWhenSysErrContains(String trigger)
Dumps a stack trace anytime trigger string is printed to System.err.
|
static void |
dumpWhenSysOutContains(String trigger)
Dumps a stack trace anytime the trigger string is printed to System.out.
|
static PrintStream |
wrapAndDumpWhenContains(PrintStream source,
String trigger)
Returns a PrintStream which will redirect all of its output to the source PrintStream.
|
public static void dump(String message, List<StackTraceElement> stack)
public static void dump(String message, StackTraceElement[] stackTrace)
public static void dump(String message, Throwable exception)
public static void dump(String message)
public static void dump(String message, int stackLimit, String... classPrefixesToExclude)
stackLimit
frames of the current stack to the system error console, excluding traces from classPrefixesToExclude
.public static void dumpWhenSysOutContains(String trigger)
public static void dumpWhenSysErrContains(String trigger)
public static PrintStream wrapAndDumpWhenContains(PrintStream source, String trigger)
source
- the returned PrintStream will delegate to this streamtrigger
- the string which triggers a stack dumppublic static List<StackTraceElement> captureStackBelow(Class<?>... clazzes)