From: Artem Bityutskiy Date: Wed, 12 Dec 2012 08:20:01 +0000 (+0200) Subject: bmaptool: make warnings and errors more visible X-Git-Tag: v2.0~68 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=70d3f7bd5c131ed7c6053b817275f2c4cd040581;p=tools%2Fbmap-tools.git bmaptool: make warnings and errors more visible People usually do not read docs and forget to use the --bmap option, and then wonder why flashing is not fast enough. bmaptool prints some kind of warning in this case, but it is not visible enough. Make it to be more visible: 1. Change the message to say that flashing will be slow. 2. Make the warning/error prefix to use capital letters. 3. Make the output to be coloured. This should hopefully draw more attention and people will notice warnings and errors more easily. Change-Id: Iccf44430c5b9e671a5d540c2966fead3aa800337 Signed-off-by: Artem Bityutskiy --- diff --git a/bmaptool b/bmaptool index 5468c0f..92d02c7 100755 --- a/bmaptool +++ b/bmaptool @@ -80,7 +80,7 @@ def copy_command(args, log): start_time = time.time() if not args.bmap: - log.info("no block map given (see the --bmap option)") + log.warning("no bmap, flashing will be slow! (use --bmap option)") log.info("falling-back to copying entire image to '%s'" % args.dest) else: log.info("block map format version %s" % writer.bmap_version) @@ -228,10 +228,15 @@ def setup_logger(loglevel): """ A helper function which sets up and configures the logger. The log level is initialized to 'loglevel'. Returns the logger object. """ + # Esc-sequences for coloured output + esc_red = '\033[91m' + esc_yellow = '\033[93m' + esc_end = '\033[0m' + # Change log level names to something less nicer than the default # all-capital 'INFO' etc. - logging.addLevelName(logging.ERROR, "error!") - logging.addLevelName(logging.WARNING, "warning!") + logging.addLevelName(logging.ERROR, esc_red + "ERROR" + esc_end) + logging.addLevelName(logging.WARNING, esc_yellow + "WARNING" + esc_end) logging.addLevelName(logging.DEBUG, "debug") logging.addLevelName(logging.INFO, "info")