[PATCH] Enable verbose yum logging once more

Jesse Keating jkeating at redhat.com
Thu Nov 15 03:14:23 UTC 2012


This time it shoves all the logging data into packaging.log

This commit has some hacks to work around yum issues.  I've discussed
with upstream and they're going to work on better APIs around logging in
the future.
---
 pyanaconda/anaconda_log.py         |  7 +++++++
 pyanaconda/packaging/yumpayload.py | 18 ++++++++++++------
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/pyanaconda/anaconda_log.py b/pyanaconda/anaconda_log.py
index 046cca7..207efe4 100644
--- a/pyanaconda/anaconda_log.py
+++ b/pyanaconda/anaconda_log.py
@@ -161,6 +161,13 @@ class AnacondaLog:
                             minLevel=logging.DEBUG)
         self.forwardToSyslog(packaging_logger)
 
+        # Create the yum logger and link it to packaging
+        yum_logger = logging.getLogger("yum")
+        yum_logger.setLevel(logging.DEBUG)
+        self.addFileHandler(PACKAGING_LOG_FILE, yum_logger,
+                            minLevel=logging.DEBUG)
+        self.forwardToSyslog(yum_logger)
+
         # Create a second logger for just the stuff we want to dup on
         # stdout.  Anything written here will also get passed up to the
         # parent loggers for processing and possibly be written to the
diff --git a/pyanaconda/packaging/yumpayload.py b/pyanaconda/packaging/yumpayload.py
index 88630db..b52fb67 100644
--- a/pyanaconda/packaging/yumpayload.py
+++ b/pyanaconda/packaging/yumpayload.py
@@ -59,6 +59,10 @@ except ImportError:
 
 try:
     import yum
+    # This is a bit of a hack to short circuit yum's internal logging
+    # handler setup.  We already set one up so we don't need it to run.
+    # yum may give us an API to fiddle this at a later time.
+    yum.logginglevels._added_handlers = True
 except ImportError:
     log.error("import of yum failed")
     yum = None
@@ -204,12 +208,14 @@ class YumPayload(PackagePayload):
             # set this now to the best default we've got ; we'll update it if/when
             # we get a base repo set up
             self._yum.preconf.releasever = self._getReleaseVersion(None)
-            # Hammer the yum logs to nothing, we log around yum.  This is
-            # to prevent stuff from leaking to the screen.  Need a less hammer
-            # approach to this so that we could have rich yum logs but clean
-            # screens
-            self._yum.preconf.debuglevel = 0
-            self._yum.preconf.errorlevel = 0
+            # Set the yum verbosity to 6, and update yum's internal logger
+            # objects to the debug level.  This is a bit of a hack requiring
+            # internal knowledge of yum, that will hopefully go away in the
+            # future with API improvements.
+            self._yum.preconf.debuglevel = 6
+            self._yum.preconf.errorlevel = 6
+            self._yum.logger.setLevel(logging.DEBUG)
+            self._yum.verbose_logger.setLevel(logging.DEBUG)
 
         self.txID = None
 
-- 
1.7.11.4



More information about the anaconda-patches mailing list