It is part of yuminstall.py cleanup (for entitlement project) outlined by clumens on https://fedoraproject.org/wiki/Anaconda/Features/YuminstallCleanup. * Remove stdout logger added to root by yum. Because we propagate from anaconda logger, anaconda log messages would go to tty1 without removing it. * Log debug messages to /tmp/yum.log. Level is set by debuglevel in our yum.conf. * Log error messages to /tmp/yum.log and to tty3. Level is set by errorlevel in our yum.conf. * Copy /tmp/yum.log to /var after installation. --- packages.py | 3 ++- yuminstall.py | 43 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/packages.py b/packages.py index ba2f9e3..0721923 100644 --- a/packages.py +++ b/packages.py @@ -82,7 +82,8 @@ def copyAnacondaLogs(anaconda): ("/tmp/syslog", "anaconda.syslog"), ("/tmp/X.log", "anaconda.xlog"), ("/tmp/program.log", "program.log"), - ("/tmp/storage.log", "storage.log")): + ("/tmp/storage.log", "storage.log"), + ("/tmp/yum.log", "yum.log")): if os.access(fn, os.R_OK): try: shutil.copyfile(fn, "%s/var/log/%s" %(anaconda.rootPath, dest)) diff --git a/yuminstall.py b/yuminstall.py index 7063595..fbd25e9 100644 --- a/yuminstall.py +++ b/yuminstall.py @@ -579,7 +579,46 @@ class AnacondaYum(YumSorter): # Override this method so yum doesn't nuke our existing logging config. def doLoggingSetup(self, *args, **kwargs): - pass + YumSorter.doLoggingSetup(self, *args, **kwargs) + + # Remove all handlers from root (added by yum) + # Another option is to set propagate = False for anaconda loggers + root = logging.getLogger() + for handler in root.handlers: + root.removeHandler(handler) + + # Replace yum handlers with ours + file_handler = logging.FileHandler("/tmp/yum.log") + formatter = logging.Formatter("[%(asctime)s] %(levelname)-8s: %(message)s") + file_handler.setFormatter(formatter) + + tty3_handler = logging.FileHandler("/dev/tty3") + tty3_formatter = logging.Formatter("%(asctime)s %(levelname)-8s: yum: %(message)s", "%H:%M:%S") + tty3_handler.setFormatter(tty3_formatter) + + # 1) yum.verbose logger + # using debuglevel value from yum.conf for level + yumdebuglogger = logging.getLogger("yum.verbose") + #yumdebuglogger.setLevel(logging.DEBUG) + + for handler in yumdebuglogger.handlers: + # remove stdout handler and others + yumdebuglogger.removeHandler(handler) + yumdebuglogger.addHandler(file_handler) + + # 2) yum logger + # using errorlevel value from yum.conf for level + yumerrorlogger = logging.getLogger("yum") + #yumerrorlogger.setLevel(logging.DEBUG) + + for handler in yumerrorlogger.handlers: + # remove stderr handler and others + yumerrorlogger.removeHandler(handler) + yumerrorlogger.addHandler(file_handler) + yumerrorlogger.addHandler(tty3_handler) + + # 3) yum.filelogging logger + # logs into logfile set in yum.conf, chrooted in /mnt/sysimage def doConfigSetup(self, fn='/tmp/anaconda-yum.conf', root='/'): if hasattr(self, "preconf"): @@ -969,6 +1008,8 @@ installroot=%s cachedir=/var/cache/yum keepcache=0 logfile=/tmp/yum.log +debuglevel=2 +errorlevel=10 metadata_expire=0 obsoletes=True pluginpath=/usr/lib/yum-plugins,/tmp/updates/yum-plugins -- 1.6.0.6 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list