tinfoil: support other fds, enable color support
PATCH 1/1 tinfoil: support other fds, enable color support
From: Christopher Larson <[email protected]>
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 <[email protected]>
--- lib/bb/tinfoil.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
lib/bb/tinfoil.py +5 -3
@@ -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)
Signature · 1 line
1.8.0.3
Quoted 8 lines · Christopher Larson
From: Christopher Larson <[email protected]>
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 <[email protected]>
Erm, ignore this, wrong list. I fail at navigating my shell history today, apparently