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>
This commit is contained in:
parent
5deae14080
commit
785e1ba012
|
@ -29,15 +29,17 @@ from bb.cooker import state
|
||||||
import bb.fetch2
|
import bb.fetch2
|
||||||
|
|
||||||
class Tinfoil:
|
class Tinfoil:
|
||||||
def __init__(self):
|
def __init__(self, output=sys.stdout):
|
||||||
# Needed to avoid deprecation warnings with python 2.6
|
# Needed to avoid deprecation warnings with python 2.6
|
||||||
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
||||||
|
|
||||||
# Set up logging
|
# Set up logging
|
||||||
self.logger = logging.getLogger('BitBake')
|
self.logger = logging.getLogger('BitBake')
|
||||||
console = logging.StreamHandler(sys.stdout)
|
console = logging.StreamHandler(output)
|
||||||
format = bb.msg.BBLogFormatter("%(levelname)s: %(message)s")
|
|
||||||
bb.msg.addDefaultlogFilter(console)
|
bb.msg.addDefaultlogFilter(console)
|
||||||
|
format = bb.msg.BBLogFormatter("%(levelname)s: %(message)s")
|
||||||
|
if output.isatty():
|
||||||
|
format.enable_color()
|
||||||
console.setFormatter(format)
|
console.setFormatter(format)
|
||||||
self.logger.addHandler(console)
|
self.logger.addHandler(console)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue