diff options
Diffstat (limited to 'import-layers/yocto-poky/bitbake/lib/bb/msg.py')
-rw-r--r-- | import-layers/yocto-poky/bitbake/lib/bb/msg.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/import-layers/yocto-poky/bitbake/lib/bb/msg.py b/import-layers/yocto-poky/bitbake/lib/bb/msg.py index b7c39fa133..90b158238f 100644 --- a/import-layers/yocto-poky/bitbake/lib/bb/msg.py +++ b/import-layers/yocto-poky/bitbake/lib/bb/msg.py @@ -201,3 +201,18 @@ def fatal(msgdomain, msg): logger = logging.getLogger("BitBake") logger.critical(msg) sys.exit(1) + +def logger_create(name, output=sys.stderr, level=logging.INFO, preserve_handlers=False, color='auto'): + """Standalone logger creation function""" + logger = logging.getLogger(name) + console = logging.StreamHandler(output) + format = bb.msg.BBLogFormatter("%(levelname)s: %(message)s") + if color == 'always' or (color == 'auto' and output.isatty()): + format.enable_color() + console.setFormatter(format) + if preserve_handlers: + logger.addHandler(console) + else: + logger.handlers = [console] + logger.setLevel(level) + return logger |