summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/msg.py
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2017-03-27 13:17:27 +1300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-03-27 20:23:19 +0100
commit614cbeddc8f092bf2748ae7555d62467f3c45f16 (patch)
treee514a07f2b452a9314461798e0b86e3f0b0ca682 /bitbake/lib/bb/msg.py
parentf41740ee8ee91a57f22ce7fa2a4b8ceeea78de0d (diff)
downloadpoky-614cbeddc8f092bf2748ae7555d62467f3c45f16.tar.gz
bitbake: lib/bb/msg: introduce logger_create() function
We use this code to set up a logger with colour in a number of different places, so create one function that does this and make some of bitbake's utility scripts use it. (Bitbake rev: b1ba7d1cc8ec33e2d081230287abd07f52136097) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/msg.py')
-rw-r--r--bitbake/lib/bb/msg.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/bitbake/lib/bb/msg.py b/bitbake/lib/bb/msg.py
index b7c39fa133..90b158238f 100644
--- a/bitbake/lib/bb/msg.py
+++ b/bitbake/lib/bb/msg.py
@@ -201,3 +201,18 @@ def fatal(msgdomain, msg):
201 logger = logging.getLogger("BitBake") 201 logger = logging.getLogger("BitBake")
202 logger.critical(msg) 202 logger.critical(msg)
203 sys.exit(1) 203 sys.exit(1)
204
205def logger_create(name, output=sys.stderr, level=logging.INFO, preserve_handlers=False, color='auto'):
206 """Standalone logger creation function"""
207 logger = logging.getLogger(name)
208 console = logging.StreamHandler(output)
209 format = bb.msg.BBLogFormatter("%(levelname)s: %(message)s")
210 if color == 'always' or (color == 'auto' and output.isatty()):
211 format.enable_color()
212 console.setFormatter(format)
213 if preserve_handlers:
214 logger.addHandler(console)
215 else:
216 logger.handlers = [console]
217 logger.setLevel(level)
218 return logger