diff options
-rw-r--r-- | quantumclient/__init__.py | 7 | ||||
-rwxr-xr-x | quantumclient/cli.py | 13 |
2 files changed, 14 insertions, 6 deletions
diff --git a/quantumclient/__init__.py b/quantumclient/__init__.py index 056e0dc..461f9b8 100644 --- a/quantumclient/__init__.py +++ b/quantumclient/__init__.py @@ -216,6 +216,8 @@ class Client(object): self.key_file = key_file self.cert_file = cert_file self.logger = logger + if not self.logger: + self.logger = LOG self.auth_token = auth_token self.version = version self.action_prefix = "/v%s%s" % (version, uri_prefix) @@ -301,6 +303,11 @@ class Client(object): conn = connection_type(self.host, self.port, **certs) else: conn = connection_type(self.host, self.port) + # besides HTTP(s)Connection, we still have testConnection + if (LOG.isEnabledFor(logging.DEBUG) and + isinstance(conn, httplib.HTTPConnection)): + conn.set_debuglevel(1) + res = self._send_request(conn, method, action, body, headers) status_code = self.get_status_code(res) data = res.read() diff --git a/quantumclient/cli.py b/quantumclient/cli.py index a1a5b1d..1636639 100755 --- a/quantumclient/cli.py +++ b/quantumclient/cli.py @@ -31,9 +31,10 @@ from quantumclient.common import exceptions from quantumclient.common import utils -#Configure logger for client - cli logger is a child of it -#NOTE(salvatore-orlando): logger name does not map to package -#this is deliberate. Simplifies logger configuration +# Configure logger for client - cli logger is a child of it +# NOTE(salvatore-orlando): logger name does not map to package +# this is deliberate. Simplifies logger configuration +logging.basicConfig() LOG = logging.getLogger('quantumclient') @@ -251,9 +252,9 @@ def main(): type="int", default=9696, help="api poort") parser.add_option("-s", "--ssl", dest="ssl", action="store_true", default=False, help="use ssl") - parser.add_option("-v", "--verbose", dest="verbose", + parser.add_option("--debug", dest="debug", action="store_true", default=False, - help="turn on verbose logging") + help="print debugging output") parser.add_option("-f", "--logfile", dest="logfile", type="string", default="syslog", help="log file path") parser.add_option("-t", "--token", dest="token", @@ -264,7 +265,7 @@ def main(): help='Accepts 1.1 and 1.0, defaults to env[QUANTUM_VERSION].') options, args = parser.parse_args() - if options.verbose: + if options.debug: LOG.setLevel(logging.DEBUG) else: LOG.setLevel(logging.WARN) |