diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2017-03-27 13:17:27 +1300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-03-27 11:10:37 +0100 |
commit | b1ba7d1cc8ec33e2d081230287abd07f52136097 (patch) | |
tree | bfff3686284f88d93a1b18ae8aeeffefaad40206 /bin/bitbake-layers | |
parent | ff1ccd1db5d70b3fc9ad0d3e8f3d7b804c22bf36 (diff) | |
download | bitbake-contrib-b1ba7d1cc8ec33e2d081230287abd07f52136097.tar.gz |
lib/bb/msg: introduce logger_create() function
We use this code to set up a logger with colour in a number of different
places, so create one function that does this and make some of bitbake's
utility scripts use it.
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bin/bitbake-layers')
-rwxr-xr-x | bin/bitbake-layers | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/bin/bitbake-layers b/bin/bitbake-layers index 66fc7ca21..390ad0503 100755 --- a/bin/bitbake-layers +++ b/bin/bitbake-layers @@ -30,26 +30,9 @@ topdir = os.path.dirname(bindir) sys.path[0:0] = [os.path.join(topdir, 'lib')] import bb.tinfoil +import bb.msg -def logger_create(name, output=sys.stderr): - logger = logging.getLogger(name) - loggerhandler = logging.StreamHandler(output) - loggerhandler.setFormatter(logging.Formatter("%(levelname)s: %(message)s")) - logger.addHandler(loggerhandler) - logger.setLevel(logging.INFO) - return logger - -def logger_setup_color(logger, color='auto'): - from bb.msg import BBLogFormatter - console = logging.StreamHandler(sys.stdout) - formatter = BBLogFormatter("%(levelname)s: %(message)s") - console.setFormatter(formatter) - logger.handlers = [console] - if color == 'always' or (color == 'auto' and console.stream.isatty()): - formatter.enable_color() - - -logger = logger_create('bitbake-layers', sys.stdout) +logger = bb.msg.logger_create('bitbake-layers', sys.stdout) def main(): parser = argparse.ArgumentParser( @@ -74,7 +57,9 @@ def main(): elif global_args.quiet: logger.setLevel(logging.ERROR) - logger_setup_color(logger, global_args.color) + # Need to re-run logger_create with color argument + # (will be the same logger since it has the same name) + bb.msg.logger_create('bitbake-layers', output=sys.stdout, color=global_args.color) plugins = [] tinfoil = bb.tinfoil.Tinfoil(tracking=True) |