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/lib/bb | |
parent | 5deae140808a7d1d96ffee75cab056e3fb77e535 (diff) | |
download | poky-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/lib/bb')
-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 | |||
29 | import bb.fetch2 | 29 | import bb.fetch2 |
30 | 30 | ||
31 | class Tinfoil: | 31 | class Tinfoil: |
32 | def __init__(self): | 32 | def __init__(self, output=sys.stdout): |
33 | # Needed to avoid deprecation warnings with python 2.6 | 33 | # Needed to avoid deprecation warnings with python 2.6 |
34 | warnings.filterwarnings("ignore", category=DeprecationWarning) | 34 | warnings.filterwarnings("ignore", category=DeprecationWarning) |
35 | 35 | ||
36 | # Set up logging | 36 | # Set up logging |
37 | self.logger = logging.getLogger('BitBake') | 37 | self.logger = logging.getLogger('BitBake') |
38 | console = logging.StreamHandler(sys.stdout) | 38 | console = logging.StreamHandler(output) |
39 | format = bb.msg.BBLogFormatter("%(levelname)s: %(message)s") | ||
40 | bb.msg.addDefaultlogFilter(console) | 39 | bb.msg.addDefaultlogFilter(console) |
40 | format = bb.msg.BBLogFormatter("%(levelname)s: %(message)s") | ||
41 | if output.isatty(): | ||
42 | format.enable_color() | ||
41 | console.setFormatter(format) | 43 | console.setFormatter(format) |
42 | self.logger.addHandler(console) | 44 | self.logger.addHandler(console) |
43 | 45 | ||