From b682935055fccbbbad988e75679dfc01b0869622 Mon Sep 17 00:00:00 2001 From: Leah Klearman Date: Tue, 15 Oct 2013 09:46:46 -0700 Subject: enhance swiftclient logging * log to debug for successes and info for errors * remove dead code, neither body or raw_body are sent in kwargs * include resp.reason and response headers in logging * remove trailing \n in logging. users who want them can set logging.basicConfig(format=FORMAT) * add --info option to swift cli Change-Id: If07af46cb377f3f3d70f6c4284037241d360a8b7 --- bin/swift | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'bin') diff --git a/bin/swift b/bin/swift index 10bceca..2abb65a 100755 --- a/bin/swift +++ b/bin/swift @@ -1266,7 +1266,7 @@ if __name__ == '__main__': parser = OptionParser(version='%%prog %s' % version, usage=''' usage: %%prog [--version] [--help] [--snet] [--verbose] - [--debug] [--quiet] [--auth ] + [--debug] [--info] [--quiet] [--auth ] [--auth-version ] [--user ] [--key ] [--retries ] [--os-username ] [--os-password ] @@ -1311,8 +1311,11 @@ Examples: parser.add_option('-v', '--verbose', action='count', dest='verbose', default=1, help='Print more info') parser.add_option('--debug', action='store_true', dest='debug', - default=False, help='Show the curl commands of all http ' - 'queries.') + default=False, help='Show the curl commands and results ' + 'of all http queries regardless of result status.') + parser.add_option('--info', action='store_true', dest='info', + default=False, help='Show the curl commands and results ' + ' of all http queries which return an error.') parser.add_option('-q', '--quiet', action='store_const', dest='verbose', const=0, default=1, help='Suppress status output') parser.add_option('-A', '--auth', dest='auth', @@ -1434,9 +1437,12 @@ Examples: signal.signal(signal.SIGINT, immediate_exit) - if options.debug: + if options.debug or options.info: logger = logging.getLogger("swiftclient") - logging.basicConfig(level=logging.DEBUG) + if options.debug: + logging.basicConfig(level=logging.DEBUG) + elif options.info: + logging.basicConfig(level=logging.INFO) had_error = False -- cgit v1.2.1