[Yum-devel] [PATCH 1/2] Add rpmverbosity config. and cmd-line-option
James Antill
james at and.org
Tue Dec 22 20:17:57 UTC 2009
---
cli.py | 6 ++++++
docs/yum.8 | 5 +++++
docs/yum.conf.5 | 5 +++++
yum/config.py | 2 ++
yum/rpmtrans.py | 14 +++++++++++---
5 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/cli.py b/cli.py
index 68506f2..f787968 100644
--- a/cli.py
+++ b/cli.py
@@ -1231,6 +1231,9 @@ class YumOptionParser(OptionParser):
self.base.usage()
sys.exit(1)
+ if opts.rpmverbosity is not None:
+ self.base.conf.rpmverbosity = opts.rpmverbosity
+
# setup the progress bars/callbacks
self.base.setupProgressCallbacks()
# setup the callbacks to import gpg pubkeys and confirm them
@@ -1331,6 +1334,9 @@ class YumOptionParser(OptionParser):
group.add_option("-e", "--errorlevel", dest="errorlevel", default=None,
help=_("error output level"), type='int',
metavar='[error level]')
+ group.add_option("", "--rpmverbosity", default=None,
+ help=_("debugging output level for rpm"),
+ metavar='[debug level name]')
group.add_option("-q", "--quiet", dest="quiet", action="store_true",
help=_("quiet operation"))
group.add_option("-v", "--verbose", dest="verbose", action="store_true",
diff --git a/docs/yum.8 b/docs/yum.8
index c65fcaa..487f5d5 100644
--- a/docs/yum.8
+++ b/docs/yum.8
@@ -307,6 +307,11 @@ Configuration Option: \fBdebuglevel\fP
Sets the error level to [number] Practical range 0 \- 10. 0 means print only critical errors about which you must be told. 1 means print all errors, even ones that are not overly important. 1+ means print more errors (if any) \-e 0 is good for cron jobs.
.br
Configuration Option: \fBerrorlevel\fP
+.IP "\fB\-e, \-\-rpmverbosity=[name]\fP"
+Sets the debug level to [name] for rpm scriplets. 'info' is the default, other
+options are: 'critical', 'emergency', 'error', 'warn' and 'debug'.
+.br
+Configuration Option: \fBrpmverbosity\fP
.IP "\fB\-R, \-\-randomwait=[time in minutes]\fP"
Sets the maximum amount of time yum will wait before performing a command \- it randomizes over the time.
.IP "\fB\-C, \-\-cacheonly\fP"
diff --git a/docs/yum.conf.5 b/docs/yum.conf.5
index eab9335..d0e1490 100644
--- a/docs/yum.conf.5
+++ b/docs/yum.conf.5
@@ -57,6 +57,11 @@ Debug message output level. Practical range is 0\-10. Default is `2'.
Error message output level. Practical range is 0\-10. Default is `2'.
.IP
+\fBrpmverbosity\fR
+Debug scriptlet output level. 'info' is the default, other
+options are: 'critical', 'emergency', 'error', 'warn' and 'debug'.
+
+.IP
\fBlogfile\fR
Full directory and file name for where yum should write its log file.
diff --git a/yum/config.py b/yum/config.py
index f1e8b48..7e2d781 100644
--- a/yum/config.py
+++ b/yum/config.py
@@ -708,6 +708,8 @@ class YumConf(StartupConf):
history_record = BoolOption(True)
history_record_packages = ListOption(['yum', 'rpm'])
+ rpmverbosity = Option('info')
+
_reposlist = []
def dump(self):
diff --git a/yum/rpmtrans.py b/yum/rpmtrans.py
index cf0efeb..73f9af1 100644
--- a/yum/rpmtrans.py
+++ b/yum/rpmtrans.py
@@ -183,7 +183,7 @@ class RPMTransaction:
self.logger = logging.getLogger('yum.filelogging.RPMInstallCallback')
self.filelog = False
- self._setupOutputLogging()
+ self._setupOutputLogging(base.conf.rpmverbosity)
if not os.path.exists(self.base.conf.persistdir):
os.makedirs(self.base.conf.persistdir) # make the dir, just in case
@@ -204,14 +204,22 @@ class RPMTransaction:
return
fcntl.fcntl(fd, fcntl.F_SETFD, current_flags | flag)
- def _setupOutputLogging(self):
+ def _setupOutputLogging(self, rpmverbosity="info"):
# UGLY... set up the transaction to record output from scriptlets
io_r = tempfile.TemporaryFile()
w = os.dup(io_r.fileno())
self._readpipe = io_r
self._writepipe = os.fdopen(w, 'w+b')
self.base.ts.scriptFd = self._writepipe.fileno()
- rpm.setVerbosity(rpm.RPMLOG_INFO)
+ rpmverbosity = {'critical' : 'crit',
+ 'emergency' : 'emerg',
+ 'error' : 'err',
+ 'information' : 'info',
+ 'warn' : 'warning'}.get(rpmverbosity, rpmverbosity)
+ rpmverbosity = 'RPMLOG_' + rpmverbosity.upper()
+ if not hasattr(rpm, rpmverbosity):
+ rpmverbosity = 'RPMLOG_INFO'
+ rpm.setVerbosity(getattr(rpm, rpmverbosity))
rpm.setLogFile(self._writepipe)
def _shutdownOutputLogging(self):
--
1.6.5.2
More information about the Yum-devel
mailing list