From 53ed90beef400d095365cc4eac123a1b4d364443 Mon Sep 17 00:00:00 2001 From: Chuck Thier Date: Wed, 19 Dec 2012 17:54:06 -0600 Subject: [PATCH] Fixes console logging with non-swift middleware Fixes logging if logging to the console with non-swift middleware (such as keystone) enabled. This also fixes issues with swift in devstack Change-Id: Ib8b691b62b657a6d4ecdb1648d1fc2f3a0479982 --- swift/common/utils.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/swift/common/utils.py b/swift/common/utils.py index bf5311cafd..fbb6158870 100644 --- a/swift/common/utils.py +++ b/swift/common/utils.py @@ -628,12 +628,13 @@ class SwiftLogFormatter(logging.Formatter): # Catch log messages that were not initiated by swift # (for example, the keystone auth middleware) record.server = record.name - return logging.Formatter.format(self, record) msg = logging.Formatter.format(self, record) - if (record.txn_id and record.levelno != logging.INFO and + if (hasattr(record, 'txn_id') and record.txn_id and + record.levelno != logging.INFO and record.txn_id not in msg): msg = "%s (txn: %s)" % (msg, record.txn_id) - if (record.client_ip and record.levelno != logging.INFO and + if (hasattr(record, 'client_ip') and record.client_ip and + record.levelno != logging.INFO and record.client_ip not in msg): msg = "%s (client_ip: %s)" % (msg, record.client_ip) return msg