From b4acbd2586a2b6f43ac51779e4f958862753d2ed Mon Sep 17 00:00:00 2001 From: Jamie Lennox Date: Fri, 4 Apr 2014 15:15:44 +1000 Subject: [PATCH] Move debug logging to shell Adding channels to a logger is not the responsibility of a library. This sort of thing should be handled by an application so move the logging over to the shell. Change-Id: Ie11571d428913eba1aae5aa42a6e925228ba6808 --- cinderclient/client.py | 6 ------ cinderclient/shell.py | 9 +++++++++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/cinderclient/client.py b/cinderclient/client.py index 314532423..fe20a6de9 100644 --- a/cinderclient/client.py +++ b/cinderclient/client.py @@ -212,12 +212,6 @@ class HTTPClient(CinderClientMixin): self.auth_plugin = auth_plugin self._logger = logging.getLogger(__name__) - if self.http_log_debug and not self._logger.handlers: - ch = logging.StreamHandler() - self._logger.setLevel(logging.DEBUG) - self._logger.addHandler(ch) - if hasattr(requests, 'logging'): - requests.logging.getLogger(requests.__name__).addHandler(ch) def http_log_req(self, args, kwargs): if not self.http_log_debug: diff --git a/cinderclient/shell.py b/cinderclient/shell.py index af166a02a..83242f31e 100644 --- a/cinderclient/shell.py +++ b/cinderclient/shell.py @@ -29,6 +29,8 @@ import os import pkgutil import sys +import requests + from cinderclient import client from cinderclient import exceptions as exc from cinderclient import utils @@ -478,6 +480,13 @@ class OpenStackCinderShell(object): logger.setLevel(logging.WARNING) logger.addHandler(streamhandler) + client_logger = logging.getLogger(client.__name__) + ch = logging.StreamHandler() + client_logger.setLevel(logging.DEBUG) + client_logger.addHandler(ch) + if hasattr(requests, 'logging'): + requests.logging.getLogger(requests.__name__).addHandler(ch) + def main(self, argv): # Parse args once to find version and debug settings