when debug flag set, print stack trace to console