[OE-core] [PATCH 4/4] oe.scriptutils: also send WARNING to stderr
Christopher Larson
kergoth at gmail.com
Mon Mar 4 21:36:26 UTC 2019
From: Christopher Larson <chris_larson at mentor.com>
stderr isn't just for errors, but anything out of band. It's highly unlikely
that warning messages are anything but out of band, which makes scripting our
tools more troublesome, since the script calling it has to filter out the
warnings from stdout to get the real output.
Signed-off-by: Christopher Larson <chris_larson at mentor.com>
---
scripts/lib/scriptutils.py | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/scripts/lib/scriptutils.py b/scripts/lib/scriptutils.py
index c361d0741d..d1a50207c5 100644
--- a/scripts/lib/scriptutils.py
+++ b/scripts/lib/scriptutils.py
@@ -43,9 +43,11 @@ def logger_setup_filters(logger):
import bb.msg
console = logging.StreamHandler(sys.stdout)
+ bb.msg.addDefaultlogFilter(console)
errconsole = logging.StreamHandler(sys.stderr)
- bb.msg.addDefaultlogFilter(console, bb.msg.BBLogFilterStdOut)
- bb.msg.addDefaultlogFilter(errconsole, bb.msg.BBLogFilterStdErr)
+ bb.msg.addDefaultlogFilter(errconsole)
+ console.addFilter(lambda r: r.levelno < logging.WARNING)
+ errconsole.addFilter(lambda r: r.levelno >= logging.WARNING)
format_str = "%(levelname)s: %(message)s"
console.setFormatter(bb.msg.BBLogFormatter(format_str))
errconsole.setFormatter(bb.msg.BBLogFormatter(format_str))
--
2.20.1
More information about the Openembedded-core
mailing list