diff options
author | Christopher Larson <chris_larson@mentor.com> | 2019-03-04 21:36:23 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-03-06 10:39:25 +0000 |
commit | 6c1a511e08628f68ebb2c4e78d6d44affb465e24 (patch) | |
tree | ec68c36fa4cdd68dae021c39a204aebb0f8cd77a | |
parent | b35846c104d15e29edace0e159cb6c105d13cd59 (diff) | |
download | poky-6c1a511e08628f68ebb2c4e78d6d44affb465e24.tar.gz |
oe.scriptutils: enable color in a more flexible way
Rather than recreating handlers and forcing them, iterate over the handlers
and enable color on ones we can handle. This makes it easier to handle color
properly when we introduce the bb.msg default log filters.
(From OE-Core rev: 713f44e0e0cde9b818c214002fd8b730d422fafa)
Signed-off-by: Christopher Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | scripts/lib/scriptutils.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/scripts/lib/scriptutils.py b/scripts/lib/scriptutils.py index 3c60c3a1e6..0633c7066e 100644 --- a/scripts/lib/scriptutils.py +++ b/scripts/lib/scriptutils.py | |||
@@ -39,12 +39,12 @@ def logger_create(name, stream=None): | |||
39 | 39 | ||
40 | def logger_setup_color(logger, color='auto'): | 40 | def logger_setup_color(logger, color='auto'): |
41 | from bb.msg import BBLogFormatter | 41 | from bb.msg import BBLogFormatter |
42 | console = logging.StreamHandler(sys.stdout) | 42 | |
43 | formatter = BBLogFormatter("%(levelname)s: %(message)s") | 43 | for handler in logger.handlers: |
44 | console.setFormatter(formatter) | 44 | if (isinstance(handler, logging.StreamHandler) and |
45 | logger.handlers = [console] | 45 | isinstance(handler.formatter, BBLogFormatter)): |
46 | if color == 'always' or (color=='auto' and console.stream.isatty()): | 46 | if color == 'always' or (color == 'auto' and handler.stream.isatty()): |
47 | formatter.enable_color() | 47 | handler.formatter.enable_color() |
48 | 48 | ||
49 | 49 | ||
50 | def load_plugins(logger, plugins, pluginpath): | 50 | def load_plugins(logger, plugins, pluginpath): |
@@ -69,6 +69,7 @@ def load_plugins(logger, plugins, pluginpath): | |||
69 | plugin.plugin_init(plugins) | 69 | plugin.plugin_init(plugins) |
70 | plugins.append(plugin) | 70 | plugins.append(plugin) |
71 | 71 | ||
72 | |||
72 | def git_convert_standalone_clone(repodir): | 73 | def git_convert_standalone_clone(repodir): |
73 | """If specified directory is a git repository, ensure it's a standalone clone""" | 74 | """If specified directory is a git repository, ensure it's a standalone clone""" |
74 | import bb.process | 75 | import bb.process |