From 785e1ba01260165b81cbf69d898830fb2bc4d4a6 Mon Sep 17 00:00:00 2001 From: Christopher Larson Date: Fri, 25 Jan 2013 17:56:30 -0700 Subject: 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 Signed-off-by: Richard Purdie --- bitbake/lib/bb/tinfoil.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'bitbake/lib/bb/tinfoil.py') 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) -- cgit 1.2.3-korg