Skip to content
Permalink
Browse files
include stack trace in logged python warning messages
  • Loading branch information
jef-n committed Jan 31, 2013
1 parent ec27d28 commit 0a0a430b0ee2d5af4d05a5664f2a12271a5dfea2
Showing with 4 additions and 1 deletion.
  1. +4 −1 python/utils.py
@@ -46,8 +46,11 @@
warnings.filterwarnings("ignore", "the sets module is deprecated")

def showWarning(message, category, filename, lineno, file=None, line=None):
stk = ""
for s in traceback.format_stack()[:-2]:
stk += s.decode('utf-8', 'replace')
QgsMessageLog.logMessage(
warnings.formatwarning(message, category, filename, lineno),
"warning:%s\ntraceback:%s" % ( warnings.formatwarning(message, category, filename, lineno), stk),
QCoreApplication.translate( "Python", "Python" )
)
warnings.showwarning = showWarning

0 comments on commit 0a0a430

Please sign in to comment.