Use self.ks_logger instead of ks_logger

Currently with '--debug' option any cinder command only logs the
request from keystoneauth and not the main cinder service request.

Added keystoneauth logger to self.ks_logger so that logs can be
logged as expected.

Closes-Bug: #1606814

Change-Id: I7193aa6f43cb3186c49fc409b6e1ce7a36f596f9
This commit is contained in:
dineshbhor
2016-07-27 12:58:17 +05:30
parent 3722a2a9d5
commit 29028b86b9
2 changed files with 13 additions and 2 deletions

View File

@@ -469,8 +469,8 @@ class OpenStackCinderShell(object):
if hasattr(requests, 'logging'): if hasattr(requests, 'logging'):
requests.logging.getLogger(requests.__name__).addHandler(ch) requests.logging.getLogger(requests.__name__).addHandler(ch)
ks_logger = logging.getLogger("keystoneauth") self.ks_logger = logging.getLogger("keystoneauth")
ks_logger.setLevel(logging.DEBUG) self.ks_logger.setLevel(logging.DEBUG)
def _delimit_metadata_args(self, argv): def _delimit_metadata_args(self, argv):
"""This function adds -- separator at the appropriate spot """This function adds -- separator at the appropriate spot

View File

@@ -228,6 +228,17 @@ class ShellTest(utils.TestCase):
self.assertEqual(False, _shell.cs.client.verify_cert) self.assertEqual(False, _shell.cs.client.verify_cert)
@mock.patch.object(cinderclient.client.SessionClient, 'authenticate',
side_effect=exceptions.Unauthorized('No'))
def test_session_client_debug_logger(self, mock_session):
_shell = shell.OpenStackCinderShell()
# This "fails" but instantiates the client.
self.assertRaises(exceptions.CommandError, _shell.main,
['--debug', 'list'])
# In case of SessionClient when --debug switch is specified
# 'keystoneauth' logger should be initialized.
self.assertEqual('keystoneauth', _shell.cs.client.logger.name)
@mock.patch('keystoneauth1.session.Session.__init__', @mock.patch('keystoneauth1.session.Session.__init__',
side_effect=RuntimeError()) side_effect=RuntimeError())
def test_http_client_with_cert(self, mock_session): def test_http_client_with_cert(self, mock_session):