diff options
author | Christopher Larson <chris_larson@mentor.com> | 2013-01-25 17:56:30 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-01-31 12:46:20 +0000 |
commit | 785e1ba01260165b81cbf69d898830fb2bc4d4a6 (patch) | |
tree | 3569d1c7217ea9a42ddd8057ddecb89ea3ce3933 /bitbake | |
parent | 5deae140808a7d1d96ffee75cab056e3fb77e535 (diff) | |
download | openembedded-core-contrib-785e1ba01260165b81cbf69d898830fb2bc4d4a6.tar.gz |
bitbake: tinfoil: support other fds, enable color support
Rather than only handling sys.stdout, also support any arbitrary file object,
and enable color for the formatter if that file is a tty.
(Bitbake rev: c46db4be4cc4dc53376ed3f574b2f1c868730f2a)
Signed-off-by: Christopher Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/bb/tinfoil.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/bitbake/lib/bb/tinfoil.py b/bitbake/lib/bb/tinfoil.py index 73d8fe92a8..cb53f3e54f 100644 --- a/bitbake/lib/bb/tinfoil.py +++ b/bitbake/lib/bb/tinfoil.py @@ -29,15 +29,17 @@ from bb.cooker import state import bb.fetch2 class Tinfoil: - def __init__(self): + def __init__(self, output=sys.stdout): # Needed to avoid deprecation warnings with python 2.6 warnings.filterwarnings("ignore", category=DeprecationWarning) # Set up logging self.logger = logging.getLogger('BitBake') - console = logging.StreamHandler(sys.stdout) - format = bb.msg.BBLogFormatter("%(levelname)s: %(message)s") + console = logging.StreamHandler(output) bb.msg.addDefaultlogFilter(console) + format = bb.msg.BBLogFormatter("%(levelname)s: %(message)s") + if output.isatty(): + format.enable_color() console.setFormatter(format) self.logger.addHandler(console) |