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
This commit is contained in:
Alistair Coles 2014-11-13 12:18:41 +00:00
parent 202bbab2d0
commit e566f77a6e

@ -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('''