Commit db8d1766 authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Introduce warning logger

parent 365280ca
......@@ -179,18 +179,21 @@ def _setup_logging(silent=False, debug=False, verbose=False, include=False):
if silent:
add_handler('', logging.CRITICAL)
elif debug:
return
if debug:
add_handler('requests', logging.INFO, prefix='* ')
add_handler('clients.send', logging.DEBUG, prefix='> ')
add_handler('clients.recv', logging.DEBUG, prefix='< ')
add_handler('kamaki', logging.DEBUG, prefix='[DEBUG]: ')
elif verbose:
add_handler('requests', logging.INFO, prefix='* ')
add_handler('clients.send', logging.INFO, prefix='> ')
add_handler('clients.recv', logging.INFO, prefix='< ')
add_handler('kamaki', logging.INFO, prefix='[INFO]: ')
elif include:
add_handler('clients.recv', logging.INFO)
else:
add_handler('', logging.WARNING)
add_handler('kamaki', logging.WARNING, prefix='[WARNING]: ')
def _init_session(arguments):
......
......@@ -34,6 +34,8 @@
from kamaki.cli.config import Config
from kamaki.cli.errors import CLISyntaxError, raiseCLIError
from kamaki.cli.utils import split_input
from logging import getLogger
from argparse import ArgumentParser, ArgumentError
......@@ -43,6 +45,8 @@ except ImportError:
# progress not installed - pls, pip install progress
pass
kloger = logging.getLogger('kamaki.warning')
class Argument(object):
"""An argument that can be parsed from command line or otherwise.
......@@ -288,7 +292,7 @@ class ProgressBarArgument(FlagArgument):
try:
KamakiProgressBar
except NameError:
print('Warning: no progress bar functionality')
kloger.warning('no progress bar functionality')
def clone(self):
"""Get a modifiable copy of this bar"""
......
......@@ -198,7 +198,7 @@ class Client(object):
sendlog.info('\t%s: %s', key, val)
sendlog.info('')
if data:
sendlog.info('%s', data)
sendlog.debug('%s', data)
recvlog.info('%d %s', r.status_code, r.status)
for key, val in r.headers.items():
......
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