Skip to content

Commit 2dd1ccd

Browse files
committed
SciJavaEvent: add utility method for dumping stack
This gives us a stack trace showing where the event was published.
1 parent 7a74934 commit 2dd1ccd

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/main/java/org/scijava/event/SciJavaEvent.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
package org.scijava.event;
3434

3535
import org.scijava.AbstractContextual;
36+
import org.scijava.util.DebugUtils;
3637

3738
/**
3839
* Base class for all SciJava events.
@@ -83,6 +84,14 @@ public StackTraceElement[] getStackTrace() {
8384
return stackTrace;
8485
}
8586

87+
/**
88+
* Gets a stack trace for the calling thread when the event was published.
89+
* This method is useful for debugging what triggered an event.
90+
*/
91+
public String dumpStack() {
92+
return DebugUtils.getStackDump(getCallingThread(), getStackTrace());
93+
}
94+
8695
// Object methods --
8796

8897
@Override

0 commit comments

Comments
 (0)