summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Likins <alikins@redhat.com>2009-02-12 15:08:59 -0500
committerAdrian Likins <alikins@redhat.com>2009-02-12 15:08:59 -0500
commited20b2fa1f9e733e24a17c7983d5b411623c4ecc (patch)
treeec9b99df8aadd396ddbabbcfafd344daa8ed78e6
parentfd57bba2195c2b8405b6317755f6ad7030702dfc (diff)
downloadcertmaster-ed20b2fa1f9e733e24a17c7983d5b411623c4ecc.tar.gz
certmaster-ed20b2fa1f9e733e24a17c7983d5b411623c4ecc.tar.xz
certmaster-ed20b2fa1f9e733e24a17c7983d5b411623c4ecc.zip
add a excepthook handler for uncaught exceptions, so they get written to the log
https://fedorahosted.org/func/ticket/70
-rw-r--r--certmaster/certmaster.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/certmaster/certmaster.py b/certmaster/certmaster.py
index e4a3d17..506a029 100644
--- a/certmaster/certmaster.py
+++ b/certmaster/certmaster.py
@@ -16,7 +16,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
# standard modules
import SimpleXMLRPCServer
+import string
import sys
+import traceback
import os
import os.path
from OpenSSL import crypto
@@ -323,9 +325,24 @@ def serve(xmlrpcinstance):
xmlrpcinstance.audit_logger.logger.info("certmaster started")
server.serve_forever()
+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):
-
+
+ sys.excepthook = excepthook
cm = CertMaster('/etc/certmaster/certmaster.conf')
if "daemon" in argv or "--daemon" in argv: