From e566f77a6edca1585179e5048ee41f1edfeb94e1 Mon Sep 17 00:00:00 2001
From: Alistair Coles <alistair.coles@hp.com>
Date: Thu, 13 Nov 2014 12:18:41 +0000
Subject: [PATCH] Suppress 'No handlers...' message from keystoneclient logger

keystoneclient isn't adding a NullHandler to its logger,
so we see 'No handlers could be found for logger...'
messages when using the swift cli with keystone auth.

Since keystoneclient follows the usual pattern of
naming loggers  from module name, we can add a
NullHandler to the 'keystoneclient' logger to handle
any logging from the library.

Note that this makes no change to keystoneclient
logging being emitted when using 'swift --debug'
or 'swift --info'.

No test because I am not sure how to usefully
test this without ending up just testing a mock
of keystoneclient.

Change-Id: Ic81cf8e5a590ae9224d35e3a5b1c5f2a8c33835a
---
 swiftclient/client.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/swiftclient/client.py b/swiftclient/client.py
index d917cc24..84b50d2a 100644
--- a/swiftclient/client.py
+++ b/swiftclient/client.py
@@ -294,6 +294,8 @@ def _import_keystone_client(auth_version):
         else:
             from keystoneclient.v2_0 import client as ksclient
         from keystoneclient import exceptions
+        # prevent keystoneclient warning us that it has no log handlers
+        logging.getLogger('keystoneclient').addHandler(NullHandler())
         return ksclient, exceptions
     except ImportError:
         sys.exit('''