bitbake: knotty: make quiet option a level option

Allow you to specify -q / --quiet more than once to reduce the messages
even further. It will now operate as follows:

 Level  Option  Result
 -----  ------  ----------------------------------------
 0              Print usual output
 1      -q      Only show progress and warnings or above
 2      -qq     Only show warnings or above
 3+     -qqq    Only show errors

(Bitbake rev: 6cf2582e17c28ca04f5cfb59858c4a9778c700d4)

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Paul Eggleton 2016-12-13 20:07:01 +13:00 committed by Richard Purdie
parent 3fa98e19d5
commit 568409faa1
2 changed files with 30 additions and 9 deletions

View File

@ -179,8 +179,8 @@ class BitBakeConfigParameters(cookerdata.ConfigParameters):
parser.add_option("-D", "--debug", action="count", dest="debug", default=0, parser.add_option("-D", "--debug", action="count", dest="debug", default=0,
help="Increase the debug level. You can specify this more than once.") help="Increase the debug level. You can specify this more than once.")
parser.add_option("-q", "--quiet", action="store_true", dest="quiet", default=False, parser.add_option("-q", "--quiet", action="count", dest="quiet", default=0,
help="Output less log message data to the terminal.") help="Output less log message data to the terminal. You can specify this more than once.")
parser.add_option("-n", "--dry-run", action="store_true", dest="dry_run", default=False, parser.add_option("-n", "--dry-run", action="store_true", dest="dry_run", default=False,
help="Don't execute, just go through the motions.") help="Don't execute, just go through the motions.")

View File

@ -284,7 +284,7 @@ class TerminalFilter(object):
content = self.main_progress.update(progress) content = self.main_progress.update(progress)
print('') print('')
lines = 1 + int(len(content) / (self.columns + 1)) lines = 1 + int(len(content) / (self.columns + 1))
if not self.quiet: if self.quiet == 0:
for tasknum, task in enumerate(tasks[:(self.rows - 2)]): for tasknum, task in enumerate(tasks[:(self.rows - 2)]):
if isinstance(task, tuple): if isinstance(task, tuple):
pbar, progress, rate, start_time = task pbar, progress, rate, start_time = task
@ -353,10 +353,13 @@ def main(server, eventHandler, params, tf = TerminalFilter):
errconsole = logging.StreamHandler(sys.stderr) errconsole = logging.StreamHandler(sys.stderr)
format_str = "%(levelname)s: %(message)s" format_str = "%(levelname)s: %(message)s"
format = bb.msg.BBLogFormatter(format_str) format = bb.msg.BBLogFormatter(format_str)
if params.options.quiet: if params.options.quiet == 0:
bb.msg.addDefaultlogFilter(console, bb.msg.BBLogFilterStdOut, bb.msg.BBLogFormatter.WARNING) forcelevel = None
elif params.options.quiet > 2:
forcelevel = bb.msg.BBLogFormatter.ERROR
else: else:
bb.msg.addDefaultlogFilter(console, bb.msg.BBLogFilterStdOut) forcelevel = bb.msg.BBLogFormatter.WARNING
bb.msg.addDefaultlogFilter(console, bb.msg.BBLogFilterStdOut, forcelevel)
bb.msg.addDefaultlogFilter(errconsole, bb.msg.BBLogFilterStdErr) bb.msg.addDefaultlogFilter(errconsole, bb.msg.BBLogFilterStdErr)
console.setFormatter(format) console.setFormatter(format)
errconsole.setFormatter(format) errconsole.setFormatter(format)
@ -506,35 +509,47 @@ def main(server, eventHandler, params, tf = TerminalFilter):
logger.info(event._message) logger.info(event._message)
continue continue
if isinstance(event, bb.event.ParseStarted): if isinstance(event, bb.event.ParseStarted):
if params.options.quiet > 1:
continue
if event.total == 0: if event.total == 0:
continue continue
parseprogress = new_progress("Parsing recipes", event.total).start() parseprogress = new_progress("Parsing recipes", event.total).start()
continue continue
if isinstance(event, bb.event.ParseProgress): if isinstance(event, bb.event.ParseProgress):
if params.options.quiet > 1:
continue
if parseprogress: if parseprogress:
parseprogress.update(event.current) parseprogress.update(event.current)
else: else:
bb.warn("Got ParseProgress event for parsing that never started?") bb.warn("Got ParseProgress event for parsing that never started?")
continue continue
if isinstance(event, bb.event.ParseCompleted): if isinstance(event, bb.event.ParseCompleted):
if params.options.quiet > 1:
continue
if not parseprogress: if not parseprogress:
continue continue
parseprogress.finish() parseprogress.finish()
pasreprogress = None pasreprogress = None
if not params.options.quiet: if params.options.quiet == 0:
print(("Parsing of %d .bb files complete (%d cached, %d parsed). %d targets, %d skipped, %d masked, %d errors." print(("Parsing of %d .bb files complete (%d cached, %d parsed). %d targets, %d skipped, %d masked, %d errors."
% ( event.total, event.cached, event.parsed, event.virtuals, event.skipped, event.masked, event.errors))) % ( event.total, event.cached, event.parsed, event.virtuals, event.skipped, event.masked, event.errors)))
continue continue
if isinstance(event, bb.event.CacheLoadStarted): if isinstance(event, bb.event.CacheLoadStarted):
if params.options.quiet > 1:
continue
cacheprogress = new_progress("Loading cache", event.total).start() cacheprogress = new_progress("Loading cache", event.total).start()
continue continue
if isinstance(event, bb.event.CacheLoadProgress): if isinstance(event, bb.event.CacheLoadProgress):
if params.options.quiet > 1:
continue
cacheprogress.update(event.current) cacheprogress.update(event.current)
continue continue
if isinstance(event, bb.event.CacheLoadCompleted): if isinstance(event, bb.event.CacheLoadCompleted):
if params.options.quiet > 1:
continue
cacheprogress.finish() cacheprogress.finish()
if not params.options.quiet: if params.options.quiet == 0:
print("Loaded %d entries from dependency cache." % event.num_entries) print("Loaded %d entries from dependency cache." % event.num_entries)
continue continue
@ -620,16 +635,22 @@ def main(server, eventHandler, params, tf = TerminalFilter):
continue continue
if isinstance(event, bb.event.ProcessStarted): if isinstance(event, bb.event.ProcessStarted):
if params.options.quiet > 1:
continue
parseprogress = new_progress(event.processname, event.total) parseprogress = new_progress(event.processname, event.total)
parseprogress.start(False) parseprogress.start(False)
continue continue
if isinstance(event, bb.event.ProcessProgress): if isinstance(event, bb.event.ProcessProgress):
if params.options.quiet > 1:
continue
if parseprogress: if parseprogress:
parseprogress.update(event.progress) parseprogress.update(event.progress)
else: else:
bb.warn("Got ProcessProgress event for someting that never started?") bb.warn("Got ProcessProgress event for someting that never started?")
continue continue
if isinstance(event, bb.event.ProcessFinished): if isinstance(event, bb.event.ProcessFinished):
if params.options.quiet > 1:
continue
if parseprogress: if parseprogress:
parseprogress.finish() parseprogress.finish()
parseprogress = None parseprogress = None
@ -701,7 +722,7 @@ def main(server, eventHandler, params, tf = TerminalFilter):
if return_value and errors: if return_value and errors:
summary += pluralise("\nSummary: There was %s ERROR message shown, returning a non-zero exit code.", summary += pluralise("\nSummary: There was %s ERROR message shown, returning a non-zero exit code.",
"\nSummary: There were %s ERROR messages shown, returning a non-zero exit code.", errors) "\nSummary: There were %s ERROR messages shown, returning a non-zero exit code.", errors)
if summary and not params.options.quiet: if summary and params.options.quiet == 0:
print(summary) print(summary)
if interrupted: if interrupted: