From 68a0f1c309c01bf6f8bbe6e0e08e3e292fec61b6 Mon Sep 17 00:00:00 2001 From: Eric Harney Date: Mon, 11 Jan 2016 15:22:25 -0500 Subject: [PATCH] API Middleware fault: Log exception type This causes a fault such as the following to log the type: ERROR cinder.api.middleware.fault [req-7d2... ddf... 658...] Caught error: (pymysql.err.InternalError) (1366, u"Incorrect string value: '\\xF0\\x9F\\x8C\\x8B' for column 'display_name' at row 1") [SQL: u'INSERT... Without this info (DBDataError), it is rather difficult to determine which exception actually occurred. Change-Id: I51ca64847b7d82c4258e134161e1b23f232004e5 --- cinder/api/middleware/fault.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cinder/api/middleware/fault.py b/cinder/api/middleware/fault.py index ce56d5f90..f667ae4d8 100644 --- a/cinder/api/middleware/fault.py +++ b/cinder/api/middleware/fault.py @@ -44,7 +44,9 @@ class FaultWrapper(base_wsgi.Middleware): def _error(self, inner, req): if not isinstance(inner, exception.QuotaError): - LOG.error(_LE("Caught error: %s"), inner) + LOG.error(_LE("Caught error: %(type)s %(error)s"), + {'type': type(inner), + 'error': inner}) safe = getattr(inner, 'safe', False) headers = getattr(inner, 'headers', None) status = getattr(inner, 'code', 500) -- 2.45.2