summaryrefslogtreecommitdiff
path: root/novaclient/shell.py
diff options
context:
space:
mode:
authorTakashi NATSUME <natsume.takashi@lab.ntt.co.jp>2016-05-30 14:54:25 +0900
committerTakashi NATSUME <natsume.takashi@lab.ntt.co.jp>2016-06-08 00:10:55 +0000
commitd16c3692e69c6416a764d8af65b8a3f09ded2e0b (patch)
tree2135217209ce975ec9ac8a89f945d37afe2faf0c /novaclient/shell.py
parente8354f1098251b37b4a01af57baffe39a554db61 (diff)
downloadpython-novaclient-d16c3692e69c6416a764d8af65b8a3f09ded2e0b.tar.gz
Log request_id for each api call
Add the function to log 'x-openstack-request-id' or 'x-compute-request-id' in each API call. If the caller (e.g. heat) uses oslo.log, the caller's request id in oslo.context and the callee's request id can be output in the same log message (same line). Change-Id: I29312ce278ecfae41a688a0ddf76c24cfa0eaf6b Implements: blueprint log-request-id
Diffstat (limited to 'novaclient/shell.py')
-rw-r--r--novaclient/shell.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/novaclient/shell.py b/novaclient/shell.py
index df2f581b..a8b5c0a4 100644
--- a/novaclient/shell.py
+++ b/novaclient/shell.py
@@ -380,6 +380,9 @@ class NovaClientArgumentParser(argparse.ArgumentParser):
class OpenStackComputeShell(object):
times = []
+ def __init__(self):
+ self.client_logger = None
+
def _append_global_identity_args(self, parser, argv):
# Register the CLI arguments that have moved to the session object.
loading.register_session_argparse_arguments(parser)
@@ -698,6 +701,11 @@ class OpenStackComputeShell(object):
format=streamformat)
logging.getLogger('iso8601').setLevel(logging.WARNING)
+ self.client_logger = logging.getLogger(client.__name__)
+ ch = logging.StreamHandler()
+ self.client_logger.setLevel(logging.DEBUG)
+ self.client_logger.addHandler(ch)
+
def main(self, argv):
# Parse args once to find version and debug settings
parser = self.get_base_parser(argv)
@@ -892,7 +900,8 @@ class OpenStackComputeShell(object):
timings=args.timings, bypass_url=bypass_url,
os_cache=os_cache, http_log_debug=args.debug,
cacert=cacert, timeout=timeout,
- session=keystone_session, auth=keystone_auth)
+ session=keystone_session, auth=keystone_auth,
+ logger=self.client_logger)
if not skip_auth:
if not api_version.is_latest():