Commit 59e20eae authored by Michael Völske's avatar Michael Völske

suppress DEBUG messages by default; add flag to enable them

parent c998de44
......@@ -13,6 +13,12 @@ from __future__ import print_function
from sys import stderr
from collections import namedtuple
_log_settings = {'debug': False}
def set_verbose_logging(is_enabled):
_log_settings['debug'] = is_enabled
def colorred(m):
return "\033[91m" + m + "\033[0m"
......@@ -38,7 +44,8 @@ def lError(msg):
def lDbg(msg):
print(colorblue("[DEBUG] ") + str(msg), file=stderr)
if _log_settings['debug']:
print(colorblue("[DEBUG] ") + str(msg), file=stderr)
def lWarn(msg):
......
......@@ -122,7 +122,7 @@ def run_subcommand(subcommand, subcommandpath, params=[]):
cmd = " ".join([subcommandpath] + params)
return_value = os.system(cmd)
if return_value == 0:
lInfo("Done.")
lDbg("Done.")
else:
lError("An error occurred while executing " + cmd)
return return_value
......@@ -142,6 +142,8 @@ def main(args):
commands = get_commands(config)
parser = argparse.ArgumentParser()
parser.register('action', 'parsers', AliasedSubParsersAction)
parser.add_argument('-v', '--verbose', help='Print debug messages.',
action='store_true')
subparsers = {}
allcommands = {}
......@@ -177,6 +179,7 @@ def main(args):
parseresults = parser.parse_known_args(args)
argsdict = vars(parseresults[0])
set_verbose_logging(argsdict['verbose'])
parameter = parseresults[1]
if argsdict['<command>'] not in subparsers:
......
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