aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bb/tinfoil.py
diff options
context:
space:
mode:
authorChristopher Larson <chris_larson@mentor.com>2013-01-25 17:56:30 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-01-31 12:37:32 +0000
commitc46db4be4cc4dc53376ed3f574b2f1c868730f2a (patch)
tree6c443dc8197f39fda5fa7623d92bdea887f43e63 /lib/bb/tinfoil.py
parenta4463d7b51828c32e55dea3c0dd51966d387abac (diff)
downloadbitbake-c46db4be4cc4dc53376ed3f574b2f1c868730f2a.tar.gz
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. Signed-off-by: Christopher Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/tinfoil.py')
-rw-r--r--lib/bb/tinfoil.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/bb/tinfoil.py b/lib/bb/tinfoil.py
index 73d8fe92a..cb53f3e54 100644
--- a/lib/bb/tinfoil.py
+++ b/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)