Skip to content

Commit

Permalink
include stack trace in logged python warning messages
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Jan 31, 2013
1 parent ec27d28 commit 0a0a430
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion python/utils.py
Expand Up @@ -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
Expand Down

0 comments on commit 0a0a430

Please sign in to comment.