From 3cba7a69aa0aec0266e1c71998eb866864f0dbd1 Mon Sep 17 00:00:00 2001 From: Adrian Likins Date: Thu, 12 Feb 2009 15:03:42 -0500 Subject: add a sys.excepthook handler that logs to the func log file Fix ticket https://fedorahosted.org/func/ticket/70 --- func/minion/server.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/func/minion/server.py b/func/minion/server.py index 7a2db00..1e1b752 100644 --- a/func/minion/server.py +++ b/func/minion/server.py @@ -267,12 +267,28 @@ class FuncSSLXMLRPCServer(AuthedXMLRPCServer.AuthedSSLXMLRPCServer, return peer_cert.get_subject().CN +def excepthook(exctype, value, tracebackobj): + exctype_blurb = "Exception occured: %s" % exctype + excvalue_blurb = "Exception value: %s" % value + exctb_blurb = "Exception Info:\n%s" % string.join(traceback.format_list(traceback.extract_tb(tracebackobj))) + + print exctype_blurb + print excvalue_blurb + print exctb_blurb + + log = logger.Logger().logger + log.info(exctype_blurb) + log.info(excvalue_blurb) + log.info(exctb_blurb) + + def main(argv): """ Start things up. """ + sys.excepthook = excepthook if len(sys.argv) > 1 and sys.argv[1] == "--list-modules": module_names = module_loader.load_modules().keys() module_names.sort() -- cgit