[Yum-devel] [PATCH] Add debuglevels -2, -3, -4. BZ 873428, BZ 982088

Zdenek Pavlas zpavlas at redhat.com
Wed Jul 24 09:04:31 UTC 2013


-2: report only warnings
-3: report only errors
-4: report only critical errors

Main user for this is yum-cron.  Added "debuglevel" option
to yum-cron.conf, defaulting to -2.

Fixes a bug that prevented yum-cron to be run as user
(setCacheDir removes the preconf attribute)
---
 etc/yum-cron.conf    | 6 ++++++
 yum-cron/yum-cron.py | 5 ++---
 yum/logginglevels.py | 4 +++-
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/etc/yum-cron.conf b/etc/yum-cron.conf
index 3fc756e..5cf6b55 100644
--- a/etc/yum-cron.conf
+++ b/etc/yum-cron.conf
@@ -64,6 +64,12 @@ group_list = None
 group_package_types = mandatory, default
 
 [base]
+# Use this to filter Yum core messages
+# -2: report only warnings (default)
+# -3: report only errors
+# -4: report only critical errors
+debuglevel = -2
+
 # override yum options of the same name
 # skip_broken = True
 
diff --git a/yum-cron/yum-cron.py b/yum-cron/yum-cron.py
index 26526b7..74eb6d7 100755
--- a/yum-cron/yum-cron.py
+++ b/yum-cron/yum-cron.py
@@ -709,6 +709,7 @@ class YumCronConfig(BaseConfig):
     group_list = ListOption([])
     group_package_types = ListOption(['mandatory', 'default'])
     skip_broken = BoolOption()
+    debuglevel = IntOption(-2, -4, 10)
 
 
 class YumCronBase(yum.YumBase):
@@ -792,14 +793,12 @@ class YumCronBase(yum.YumBase):
         try :
             # Set the configuration file
             self.preconf.fn = self.opts.yum_config_file
+            self.preconf.debuglevel = self.opts.debuglevel
 
             # if we are not root do the special subdir thing
             if os.geteuid() != 0:
                 self.setCacheDir()
 
-            # Turn off the plugins line
-            self.preconf.debuglevel = 0
-
             # Create the configuration
             self.conf
 
diff --git a/yum/logginglevels.py b/yum/logginglevels.py
index dfdd90c..8a811ae 100644
--- a/yum/logginglevels.py
+++ b/yum/logginglevels.py
@@ -87,7 +87,9 @@ def logLevelFromErrorLevel(error_level):
 
 def logLevelFromDebugLevel(debug_level):
     """ Convert an old-style debug logging level to the new style. """
-    debug_table = {-1 : __NO_LOGGING, 0 : logging.INFO, 1 : INFO_1, 2 : INFO_2,
+    debug_table = {
+        -4 : logging.CRITICAL, -3 : logging.ERROR, -2 : logging.WARNING,
+        -1 : __NO_LOGGING, 0 : logging.INFO, 1 : INFO_1, 2 : INFO_2,
         3 : logging.DEBUG, 4 : DEBUG_1, 5 : DEBUG_2, 6 : DEBUG_3, 7 : DEBUG_4}
 
     return __convertLevel(debug_level, debug_table)
-- 
1.7.11.7



More information about the Yum-devel mailing list