[RFC] log deprecation warnings as a full traceback to .bzr.log.?
John Arbash Meinel
john at arbash-meinel.com
Mon Apr 30 14:56:22 BST 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Robert Collins wrote:
> https://bugs.launchpad.net/bugs/111045 noted that the user saw an error
> but didn't see anything related to it in .bzr.log.
>
> -Rob
I think it is tricky to do, since we are letting python handle the
display of deprecation warnings.
But I can certainly see it as useful. Just like we log full tracebacks
for errors that we think are single-line (user).
I'm just not sure how we would do it, since an Exception isn't raised.
(Unless you run with -Werror, in which case we would show a traceback).
Ahh... it looks like you can munge warnings.showwarning().
>>> import warnings
>>> help(warnings)
...
showwarning(message, category, filename, lineno, file=None)
Hook to write a warning to a file; replace if you like.
So we could write something like:
import traceback
import warnings
_orig_showwarning = warnings.showwarning
def showwarning_log_traceback(*args, **kwargs):
formatted_stack = ''.join(traceback.format_stack())
trace.mutter('Warning encountered:\s%s', formatted_stack)
_orig_showwarning(*args, **kwargs)
warnings.showwarning = showwarning_log_traceback
John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFGNfWFJdeBCYSNAAMRAsivAJ9nrUL8pTPQ7iHBt/HAva8ACKDT0ACcDgld
blJjvuzuGfrXQ19bLNPXFx4=
=Ml1H
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list