Simply grab the stack trace via (new Error()).getStackTrace()
Only bother trying to grab the stacktrace if we are in a debugger build...