diff options
author | Adrian Likins <alikins@redhat.com> | 2009-02-12 15:03:42 -0500 |
---|---|---|
committer | Adrian Likins <alikins@redhat.com> | 2009-02-12 15:03:42 -0500 |
commit | 3cba7a69aa0aec0266e1c71998eb866864f0dbd1 (patch) | |
tree | c150ef4eccfd21678aee354766b5bcb40b8465b2 | |
parent | b69f356eca283dcc9e80897da5169fde3b3456f7 (diff) | |
download | func-3cba7a69aa0aec0266e1c71998eb866864f0dbd1.tar.gz func-3cba7a69aa0aec0266e1c71998eb866864f0dbd1.tar.xz func-3cba7a69aa0aec0266e1c71998eb866864f0dbd1.zip |
add a sys.excepthook handler that logs to the func log file
Fix ticket https://fedorahosted.org/func/ticket/70
-rw-r--r-- | func/minion/server.py | 16 |
1 files changed, 16 insertions, 0 deletions
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() |