summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlvaro Lopez Garcia <aloga@ifca.unican.es>2013-03-13 16:47:16 +0100
committerAlvaro Lopez Garcia <aloga@ifca.unican.es>2013-03-15 10:28:12 +0100
commite9e05d7dfe6809adc009f79ca3ee08a332488094 (patch)
treed36036832476636897c5344cdee93d8964628ed3
parentc5b579926feb208c785f028d48c6eaf9c36768fc (diff)
downloadpython-novaclient-e9e05d7dfe6809adc009f79ca3ee08a332488094.tar.gz
Set up debug level on root logger.
If we set up the debug level on the root logger, this can be used by the submodules that might need to print some debug output. Change-Id: I2a00b40d4748cc62e6081df7d6a44622f5ad4467
-rw-r--r--novaclient/client.py10
-rw-r--r--novaclient/shell.py8
2 files changed, 12 insertions, 6 deletions
diff --git a/novaclient/client.py b/novaclient/client.py
index e49aa4c8..73595701 100644
--- a/novaclient/client.py
+++ b/novaclient/client.py
@@ -97,11 +97,17 @@ class HTTPClient(object):
self._logger = logging.getLogger(__name__)
if self.http_log_debug:
+ # Logging level is already set on the root logger
ch = logging.StreamHandler()
- self._logger.setLevel(logging.DEBUG)
self._logger.addHandler(ch)
+ self._logger.propagate = False
if hasattr(requests, 'logging'):
- requests.logging.getLogger(requests.__name__).addHandler(ch)
+ rql = requests.logging.getLogger(requests.__name__)
+ rql.addHandler(ch)
+ # Since we have already setup the root logger on debug, we
+ # have to set it up here on WARNING (its original level)
+ # otherwise we will get all the requests logging messanges
+ rql.setLevel(logging.WARNING)
def use_token_cache(self, use_it):
self.os_cache = use_it
diff --git a/novaclient/shell.py b/novaclient/shell.py
index bf56b0fd..8b4aea51 100644
--- a/novaclient/shell.py
+++ b/novaclient/shell.py
@@ -507,11 +507,11 @@ class OpenStackComputeShell(object):
if not debug:
return
- streamhandler = logging.StreamHandler()
streamformat = "%(levelname)s (%(module)s:%(lineno)d) %(message)s"
- streamhandler.setFormatter(logging.Formatter(streamformat))
- logger.setLevel(logging.DEBUG)
- logger.addHandler(streamhandler)
+ # Set up the root logger to debug so that the submodules can
+ # print debug messages
+ logging.basicConfig(level=logging.DEBUG,
+ format=streamformat)
def main(self, argv):
# Parse args once to find version and debug settings