From 4ad6d9e1e722031d290948023898e4f9ff531155 Mon Sep 17 00:00:00 2001 From: bloodearnest Date: Fri, 5 Feb 2016 11:11:37 +0000 Subject: [PATCH] Let logging module handle traceback printing Manually including the traceback in the log msg causes some issues when interacting with log formats, and in one case was causing the traceback to be printed twice. --- gunicorn/arbiter.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/gunicorn/arbiter.py b/gunicorn/arbiter.py index 0b493133de..48df93e6a7 100644 --- a/gunicorn/arbiter.py +++ b/gunicorn/arbiter.py @@ -207,8 +207,8 @@ def run(self): except SystemExit: raise except Exception: - self.log.info("Unhandled exception in main loop:\n%s", - traceback.format_exc()) + self.log.info("Unhandled exception in main loop", + exc_info=1) self.stop(False) if self.pidfile is not None: self.pidfile.unlink() @@ -518,14 +518,13 @@ def spawn_worker(self): except SystemExit: raise except AppImportError as e: - self.log.debug("Exception while loading the application: \n%s", - traceback.format_exc()) + self.log.debug("Exception while loading the application", + exc_info=1) print("%s" % e, file=sys.stderr) sys.stderr.flush() sys.exit(self.APP_LOAD_ERROR) except: - self.log.exception("Exception in worker process:\n%s", - traceback.format_exc()) + self.log.exception("Exception in worker process"), if not worker.booted: sys.exit(self.WORKER_BOOT_ERROR) sys.exit(-1)