[OE-core] [PATCH 2/3] oe.scriptutils: add logger_setup_filters
Christopher Larson
kergoth at gmail.com
Wed Sep 23 18:24:18 UTC 2015
From: Christopher Larson <chris_larson at mentor.com>
This function sets up the default bb.msg formatter and log filters, which by
default sends ERROR messages to stderr rather than stdout.
Signed-off-by: Christopher Larson <chris_larson at mentor.com>
---
scripts/lib/scriptutils.py | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/scripts/lib/scriptutils.py b/scripts/lib/scriptutils.py
index 3c165eb..db0394a 100644
--- a/scripts/lib/scriptutils.py
+++ b/scripts/lib/scriptutils.py
@@ -20,6 +20,7 @@ import os
import logging
import glob
+
def logger_create(name):
logger = logging.getLogger(name)
loggerhandler = logging.StreamHandler()
@@ -28,6 +29,20 @@ def logger_create(name):
logger.setLevel(logging.INFO)
return logger
+
+def logger_setup_filters(logger):
+ import bb.msg
+
+ console = logging.StreamHandler(sys.stdout)
+ errconsole = logging.StreamHandler(sys.stderr)
+ bb.msg.addDefaultlogFilter(console, bb.msg.BBLogFilterStdOut)
+ bb.msg.addDefaultlogFilter(errconsole, bb.msg.BBLogFilterStdErr)
+ format_str = "%(levelname)s: %(message)s"
+ console.setFormatter(bb.msg.BBLogFormatter(format_str))
+ errconsole.setFormatter(bb.msg.BBLogFormatter(format_str))
+ logger.handlers = [console, errconsole]
+
+
def logger_setup_color(logger, color='auto'):
from bb.msg import BBLogFormatter
--
2.2.1
More information about the Openembedded-core
mailing list