]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
tinfoil: remove logging handler at shutdown
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Mon, 21 Sep 2015 13:07:57 +0000 (16:07 +0300)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 23 Sep 2015 21:43:49 +0000 (22:43 +0100)
Otherwise the logger gets multiple handers (and the user get duplicate
logging output) if another tinfoil instance is initialized after one is
shut down().

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
lib/bb/tinfoil.py

index 1ea46d8eecfb5224723d762094b9e0ec289395ef..7aa653f1aab77d26cd73536998f347398e5b2a3c 100644 (file)
@@ -36,13 +36,13 @@ class Tinfoil:
 
         # Set up logging
         self.logger = logging.getLogger('BitBake')
-        console = logging.StreamHandler(output)
-        bb.msg.addDefaultlogFilter(console)
+        self._log_hdlr = logging.StreamHandler(output)
+        bb.msg.addDefaultlogFilter(self._log_hdlr)
         format = bb.msg.BBLogFormatter("%(levelname)s: %(message)s")
         if output.isatty():
             format.enable_color()
-        console.setFormatter(format)
-        self.logger.addHandler(console)
+        self._log_hdlr.setFormatter(format)
+        self.logger.addHandler(self._log_hdlr)
 
         self.config = CookerConfiguration()
         configparams = TinfoilConfigParameters(parse_only=True)
@@ -88,6 +88,7 @@ class Tinfoil:
         self.cooker.shutdown(force=True)
         self.cooker.post_serve()
         self.cooker.unlockBitbake()
+        self.logger.removeHandler(self._log_hdlr)
 
 class TinfoilConfigParameters(ConfigParameters):