-def log_exc(msg="",name=None):
- """Log the traceback resulting from an exception."""
- if name:
- log("%s: EXCEPTION caught <%s> \n %s" %(name, msg, traceback.format_exc()))
- else:
- log("EXCEPTION caught <%s> \n %s" %(msg, traceback.format_exc()))
+date_width = 24
+def log_exc(msg="", name=None):
+ """Log traceback resulting from an exception."""
+ printout = ""
+ if name:
+ printout += "%s: "%name
+ printout += "EXCEPTION caught <%s> \n" % msg
+ for frame in traceback.format_exc().split("\n"):
+ printout += (date_width+2)*" " + "%s\n" % frame
+ log(printout)
+
+def log_trace(msg="", name=None):
+ """Log current stack"""
+ printout = ""
+ if name:
+ printout += "%s: " % name
+ printout += "LOGTRACE\n"
+ for frame in traceback.format_stack():
+ printout += "..." + frame
+ log(printout)
+