Commit 8f180e69 authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Merge branch 'feature-output' into develop

parents 6834fc64 1a3c18fd
......@@ -43,6 +43,7 @@ from kamaki.cli.errors import CLIError
_help = False
_debug = False
_include = False
_verbose = False
_colors = False
kloger = None
......@@ -188,8 +189,9 @@ def _setup_logging(silent=False, debug=False, verbose=False, include=False):
add_handler('clients.send', logging.INFO, prefix='> ')
add_handler('clients.recv', logging.INFO, prefix='< ')
add_handler('kamaki', logging.INFO, prefix='(i): ')
elif include:
add_handler('clients.recv', logging.INFO)
if include:
add_handler('data.send', logging.INFO, prefix='>[data]: ')
add_handler('data.recv', logging.INFO, prefix='<[data]: ')
add_handler('kamaki', logging.WARNING, prefix='(warning): ')
global kloger
kloger = logging.getLogger('kamaki')
......@@ -200,6 +202,8 @@ def _init_session(arguments):
_help = arguments['help'].value
global _debug
_debug = arguments['debug'].value
global _include
_include = arguments['include'].value
global _verbose
_verbose = arguments['verbose'].value
global _colors
......@@ -208,7 +212,6 @@ def _init_session(arguments):
from kamaki.cli.utils import remove_colors
remove_colors()
_silent = arguments['silent'].value
_include = arguments['include'].value
_setup_logging(_silent, _debug, _verbose, _include)
......
......@@ -373,7 +373,7 @@ class ProgressBarArgument(FlagArgument):
_arguments = dict(config=_config_arg,
help=Argument(0, 'Show help message', ('-h', '--help')),
debug=FlagArgument('Include debug output', ('-d', '--debug')),
include=FlagArgument('Include protocol headers in the output',
include=FlagArgument('Include raw connection data in the output',
('-i', '--include')),
silent=FlagArgument('Do not output anything', ('-s', '--silent')),
verbose=FlagArgument('More info at response', ('-v', '--verbose')),
......
......@@ -40,7 +40,9 @@ from kamaki.clients.connection.errors import HTTPConnectionError
from kamaki.clients.connection.errors import HTTPResponseError
sendlog = logging.getLogger('clients.send')
datasendlog = logging.getLogger('data.send')
recvlog = logging.getLogger('clients.recv')
datarecvlog = logging.getLogger('data.recv')
class ClientError(Exception):
......@@ -203,13 +205,13 @@ class Client(object):
sendlog.info('\t%s: %s', key, val)
sendlog.info('')
if data:
sendlog.info(data[:256] + ' ...')
datasendlog.info(data)
recvlog.info('%d %s', r.status_code, r.status)
for key, val in r.headers.items():
recvlog.info('%s: %s', key, val)
if r.content:
recvlog.info(r.content[:256] + ' ...')
datarecvlog.info(r.content)
except (HTTPResponseError, HTTPConnectionError) as err:
from traceback import format_stack
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment