[PATCH] virt-manager: log uncaught exceptions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The attached patch alters sys.excepthook to log uncaught exceptions.
Currently in virt-manager.py the main() call is wrapped in a try...except
block that was assumed to log uncaught exceptions, but the gtk.main() loop
does not raise exceptions (hence why the app does not crash anytime an
exception is uncaught).

Info on this was found here:
http://faq.pygtk.org/index.py?req=show&file=faq20.010.htp

Any comments welcome.

- Cole

-- 
Cole Robinson
crobinso@xxxxxxxxxx
diff -r 27780aa800d5 src/virt-manager.py.in
--- a/src/virt-manager.py.in	Mon Nov 12 13:04:59 2007 -0500
+++ b/src/virt-manager.py.in	Wed Nov 14 12:55:38 2007 -0500
@@ -123,6 +123,14 @@ def setup_logging():
     fileHandler.setFormatter(logging.Formatter(FILE_FORMAT, DATEFMT))
     rootLogger.addHandler(fileHandler)
     logging.info("Application startup")
+
+    # Log uncaught exceptions
+    def exception_log(type, val, tb):
+        import traceback
+        str = traceback.format_exception(type, val, tb)
+        logging.exception("".join(str))
+        sys.__excepthook__(type, val, tb)
+    sys.excepthook = exception_log
 
 def parse_commandline():
     optParser = OptionParser()
_______________________________________________
et-mgmt-tools mailing list
et-mgmt-tools@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/et-mgmt-tools

[Index of Archives]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux