[yum-cvs] yum callback.py, 1.27, 1.28 cli.py, 1.217, 1.218 output.py, 1.67, 1.68 shell.py, 1.28, 1.29 yummain.py, 1.98, 1.99

Jeremy Katz katzj at linux.duke.edu
Fri Jun 23 14:26:19 UTC 2006


Update of /home/groups/yum/cvs/yum
In directory login1.linux.duke.edu:/tmp/cvs-serv19994

Modified Files:
	callback.py cli.py output.py shell.py yummain.py 
Log Message:
>From James Bowes <jbowes at redhat.com> and modified by me to bring it up
to current HEAD

Move yum from using a custom logging implementation to python's logging 
module.  Full details about the changes at
https://lists.dulug.duke.edu/pipermail/yum-devel/2006-May/002235.html


Index: callback.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/callback.py,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- callback.py	10 May 2006 18:54:12 -0000	1.27
+++ callback.py	23 Jun 2006 14:26:17 -0000	1.28
@@ -18,6 +18,7 @@
 import rpm
 import os
 import sys
+import logging
 from yum.constants import *
 
 from i18n import _
@@ -32,7 +33,7 @@
         self.total_removed = 0
         self.mark = "#"
         self.marks = 27
-        self.filelog = None
+        self.logger = logging.getLogger('yum.filelogging.RPMInstallCallback')
 
         self.myprocess = { TS_UPDATE : 'Updating', 
                            TS_ERASE: 'Erasing',
@@ -136,10 +137,9 @@
                     except KeyError, e:
                         pass
 
-                    if self.filelog:
-                        pkgrep = self._logPkgString(hdr)
-                        msg = '%s: %s' % (processed, pkgrep)
-                        self.filelog(0, msg)
+                    pkgrep = self._logPkgString(hdr)
+                    msg = '%s: %s' % (processed, pkgrep)
+                    self.logger.info(msg)
 
 
         elif what == rpm.RPMCALLBACK_INST_PROGRESS:
@@ -194,7 +194,7 @@
             self.total_removed += 1
             if h not in self.installed_pkg_names:
                 logmsg = _('Erased: %s' % (h))
-                if self.filelog: self.filelog(0, logmsg)
+                self.logger.info(logmsg)
             
             if self.output and sys.stdout.isatty():
                 if h not in self.installed_pkg_names:

Index: cli.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/cli.py,v
retrieving revision 1.217
retrieving revision 1.218
diff -u -r1.217 -r1.218
--- cli.py	21 Jun 2006 17:07:44 -0000	1.217
+++ cli.py	23 Jun 2006 14:26:17 -0000	1.218
@@ -24,6 +24,7 @@
 import fcntl
 import fnmatch
 import re
+import logging
 from optparse import OptionParser
 
 import output
@@ -35,8 +36,8 @@
 import rpmUtils.arch
 from rpmUtils.miscutils import compareEVR
 from yum.packages import parsePackages, YumInstalledPackage, YumLocalPackage
-from yum.logger import Logger, SysLogger, LogContainer
 from yum import pgpmsg
+from yum import logginglevels
 from i18n import _
 import callback
 import urlgrabber
@@ -54,6 +55,8 @@
     def __init__(self):
         yum.YumBase.__init__(self)
         self.in_shell = False
+        self.logger = logging.getLogger("yum.cli")
+        self.verbose_logger = logging.getLogger("yum.verbose.cli")
         self.yum_cli_commands = ['update', 'install','info', 'list', 'erase',
                                 'grouplist', 'groupupdate', 'groupinstall',
                                 'groupremove', 'groupinfo', 'makecache',
@@ -68,17 +71,19 @@
            and sets up the basics of the repository"""
         
         if hasattr(self, 'pkgSack') and thisrepo is None:
-            self.log(7, 'skipping reposetup, pkgsack exists')
+            self.verbose_logger.log(logginglevels.DEBUG_4,
+                'skipping reposetup, pkgsack exists')
             return
-            
-        self.log(2, 'Setting up repositories')
+      
+        self.verbose_logger.log(logginglevels.INFO_2, 'Setting up repositories')
 
         # Call parent class to do the bulk of work 
         # (this also ensures that reposetup plugin hook is called)
         yum.YumBase.doRepoSetup(self, thisrepo=thisrepo)
 
         if dosack: # so we can make the dirs and grab the repomd.xml but not import the md
-            self.log(2, 'Reading repository metadata in from local files')
+            self.verbose_logger.log(logginglevels.INFO_2,
+                'Reading repository metadata in from local files')
             self.doSackSetup(thisrepo=thisrepo)
     
         
@@ -87,9 +92,6 @@
         sets up self.conf and self.cmds as well as logger objects 
         in base instance"""
         
-        # setup our errorlog object 
-        self.errorlog = Logger(threshold=2, file_object=sys.stderr)
-    
         def repo_optcb(optobj, opt, value, parser):
             '''Callback for the enablerepo and disablerepo option. 
             
@@ -179,13 +181,25 @@
                     debuglevel=opts.debuglevel,
                     errorlevel=opts.errorlevel)
         except yum.Errors.ConfigError, e:
-            self.errorlog(0, _('Config Error: %s') % e)
+            self.logger.critical(_('Config Error: %s'), e)
             sys.exit(1)
         except ValueError, e:
-            self.errorlog(0, _('Options Error: %s') % e)
+            self.logger.critical(_('Options Error: %s'), e)
             self.usage()
             sys.exit(1)
 
+        # who are we:
+        self.conf.uid = os.geteuid()
+
+        # Setup debug and error levels
+        if opts.debuglevel is not None:
+            self.startupconf.debuglevel = opts.debuglevel
+        if opts.errorlevel is not None:
+            self.startupconf.errorlevel = opts.errorlevel
+             
+        logginglevels.doLoggingSetup(self.conf.uid, self.conf.logfile,
+            self.conf.errorlevel, self.conf.debuglevel)
+
         # Now parse the command line for real
         (opts, self.cmds) = self.optparser.parse_args()
 
@@ -201,44 +215,9 @@
             # config file is parsed and moving us forward
             # set some things in it.
                 
-            # who are we:
-            self.conf.uid = os.geteuid()
-
             # version of yum
             self.conf.yumversion = yum.__version__
             
-            # syslog-style log
-            if self.conf.uid == 0:
-                logpath = os.path.dirname(self.conf.logfile)
-                if not os.path.exists(logpath):
-                    try:
-                        os.makedirs(logpath, mode=0755)
-                    except OSError, e:
-                        self.errorlog(0, _('Cannot make directory for logfile %s' % logpath))
-                        sys.exit(1)
-                try:
-                    logfd = os.open(self.conf.logfile, os.O_WRONLY |
-                                    os.O_APPEND | os.O_CREAT, 0644)
-                except OSError, e:
-                    self.errorlog(0, _('Cannot open logfile %s' % self.conf.logfile))
-                    sys.exit(1)
-
-                logfile =  os.fdopen(logfd, 'a')
-                fcntl.fcntl(logfd, fcntl.F_SETFD)
-            
-                                      
-                filelog_object = Logger(threshold = 10, file_object = logfile, 
-                                preprefix = self.printtime)
-            else:
-                filelog_object = Logger(threshold = 10, file_object = None, 
-                                preprefix = self.printtime)
-
-            syslog_object = SysLogger(threshold = 10, 
-                                      facility=self.conf.syslog_facility,
-                                      ident='yum')
-            
-            self.filelog = LogContainer([syslog_object, filelog_object])
-
             # Handle remaining options
             if opts.assumeyes:
                 self.conf.assumeyes =1
@@ -263,7 +242,7 @@
                     excludelist.append(exclude)
                     self.conf.exclude = excludelist
                 except yum.Errors.ConfigError, e:
-                    self.errorlog(0, _(e))
+                    self.logger.critical(e)
                     self.usage()
                     sys.exit(1)
                
@@ -275,12 +254,12 @@
                     elif opt == '--disablerepo':
                         self.repos.disableRepo(repoexp)
                 except yum.Errors.ConfigError, e:
-                    self.errorlog(0, _(e))
+                    self.logger.critical(e)
                     self.usage()
                     sys.exit(1)
                             
         except ValueError, e:
-            self.errorlog(0, _('Options Error: %s') % e)
+            self.logger.critical(_('Options Error: %s'), e)
             self.usage()
             sys.exit(1)
          
@@ -306,23 +285,19 @@
         # run the sleep - if it's unchanged then it won't matter
         time.sleep(sleeptime)
 
-    def doLoggingSetup(self, debuglevel, errorlevel):
-        self.log = Logger(threshold=debuglevel, file_object=sys.stdout)
-        self.errorlog.threshold = errorlevel
-
     def parseCommands(self, mycommands=[]):
         """reads self.cmds and parses them out to make sure that the requested 
         base command + argument makes any sense at all""" 
 
-        self.log(3, 'Yum Version: %s' % self.conf.yumversion)
-        self.log(3, 'COMMAND: %s' % self.cmdstring)
-        self.log(3, 'Installroot: %s' % self.conf.installroot)
+        self.verbose_logger.debug('Yum Version: %s', self.conf.yumversion)
+        self.verbose_logger.debug('COMMAND: %s', self.cmdstring)
+        self.verbose_logger.debug('Installroot: %s', self.conf.installroot)
         if len(self.conf.commands) == 0 and len(self.cmds) < 1:
             self.cmds = self.conf.commands
         else:
             self.conf.commands = self.cmds
         if len(self.cmds) < 1:
-            self.errorlog(0, _('You need to give some command'))
+            self.logger.critical(_('You need to give some command'))
             self.usage()
             raise CliError
             
@@ -330,9 +305,9 @@
         self.extcmds = self.cmds[1:] # out extended arguments/commands
         
         if len(self.extcmds) > 0:
-            self.log(3, 'Ext Commands:\n')
+            self.verbose_logger.debug('Ext Commands:\n')
             for arg in self.extcmds:
-                self.log(3, '   %s' % arg)
+                self.verbose_logger.debug('   %s', arg)
         
         if self.basecmd not in self.yum_cli_commands:
             self.usage()
@@ -343,7 +318,7 @@
                                 'groupupdate', 'groupinstall', 'remove',
                                 'groupremove', 'importkey', 'makecache', 
                                 'localinstall', 'localupdate']:
-                self.errorlog(0, _('You need to be root to perform this command.'))
+                self.logger.critical(_('You need to be root to perform this command.'))
                 raise CliError
 
         if self.basecmd in ['install', 'update', 'upgrade', 'groupinstall',
@@ -366,32 +341,31 @@
 
 For more information contact your distribution or package provider.
 """)
-                        self.errorlog(0, msg)
+                        self.logger.critical(msg)
                         raise CliError
 
                 
         if self.basecmd in ['install', 'erase', 'remove', 'localinstall', 'localupdate', 'deplist']:
             if len(self.extcmds) == 0:
-                self.errorlog(0, _('Error: Need to pass a list of pkgs to %s') % self.basecmd)
+                self.logger.critical(_('Error: Need to pass a list of pkgs to %s') % self.basecmd)
                 self.usage()
                 raise CliError
     
         elif self.basecmd in ['provides', 'search', 'whatprovides']:
             if len(self.extcmds) == 0:
-                self.errorlog(0, _('Error: Need an item to match'))
+                self.logger.critical(_('Error: Need an item to match'))
                 self.usage()
                 raise CliError
                 
         elif self.basecmd in ['groupupdate', 'groupinstall', 'groupremove', 'groupinfo']:
             if len(self.extcmds) == 0:
-                self.errorlog(0, _('Error: Need a group or list of groups'))
+                self.logger.critical(_('Error: Need a group or list of groups'))
                 self.usage()
                 raise CliError
                 
         elif self.basecmd == 'clean':
             if len(self.extcmds) == 0:
-                self.errorlog(0,
-                    _('Error: clean requires an option: headers, packages, dbcache, metadata, plugins, all'))
+                self.logger.critical(_('Error: clean requires an option: headers, packages, dbcache, metadata, plugins, all'))
             for cmd in self.extcmds:
                 if cmd not in ['headers', 'packages', 'metadata', 'dbcache', 'plugins', 'all']:
                     self.usage()
@@ -399,17 +373,18 @@
                     
         elif self.basecmd == 'shell':
             if len(self.extcmds) == 0:
-                self.log(3, "No argument to shell")
+                self.verbose_logger.debug("No argument to shell")
                 pass
             elif len(self.extcmds) == 1:
-                self.log(3, "Filename passed to shell: %s" % self.extcmds[0])              
+                self.verbose_logger.debug("Filename passed to shell: %s", 
+                    self.extcmds[0])              
                 if not os.path.isfile(self.extcmds[0]):
-                    self.errorlog(
-                        0, _("File: %s given has argument to shell does not exists." % self.extcmds))
+                    self.logger.critical(
+                        _("File: %s given has argument to shell does not exists."), self.extcmds)
                     self.usage()
                     raise CliError
             else:
-                self.errorlog(0,_("Error: more than one file given as argument to shell."))
+                self.logger.critical(_("Error: more than one file given as argument to shell."))
                 self.usage()
                 raise CliError
               
@@ -425,7 +400,7 @@
     def doShell(self):
         """do a shell-like interface for yum commands"""
 
-        self.log(2, 'Setting up Yum Shell')
+        self.verbose_logger.log(logginglevels.INFO_2, 'Setting up Yum Shell')
         self.in_shell = True
         self.doTsSetup()
         self.doRpmDBSetup()
@@ -456,14 +431,14 @@
             return 1, [str(e)]
         
         if self.basecmd == 'install':
-            self.log(2, "Setting up Install Process")
+            self.verbose_logger.log(logginglevels.INFO_2, "Setting up Install Process")
             try:
                 return self.installPkgs()
             except yum.Errors.YumBaseError, e:
                 return 1, [str(e)]
         
         elif self.basecmd == 'update':
-            self.log(2, "Setting up Update Process")
+            self.verbose_logger.log(logginglevels.INFO_2, "Setting up Update Process")
             try:
                 return self.updatePkgs()
             except yum.Errors.YumBaseError, e:
@@ -472,7 +447,7 @@
             
         elif self.basecmd == 'upgrade':
             self.conf.obsoletes = 1
-            self.log(2, "Setting up Upgrade Process")
+            self.verbose_logger.log(logginglevels.INFO_2, "Setting up Upgrade Process")
             try:
                 return self.updatePkgs()
             except yum.Errors.YumBaseError, e:
@@ -480,7 +455,7 @@
             
             
         elif self.basecmd in ['erase', 'remove']:
-            self.log(2, "Setting up Remove Process")
+            self.verbose_logger.log(logginglevels.INFO_2, "Setting up Remove Process")
             try:
                 return self.erasePkgs()
             except yum.Errors.YumBaseError, e:
@@ -488,7 +463,8 @@
             
 
         elif self.basecmd in ['localinstall', 'localupdate']:
-            self.log(2, "Setting up Local Package Process")
+            self.verbose_logger.log(logginglevels.INFO_2,
+                "Setting up Local Package Process")
             updateonly=0
             if self.basecmd == 'localupdate': updateonly=1
                 
@@ -532,7 +508,7 @@
                 return result, []
             
         elif self.basecmd in ['deplist']:
-           self.log(2, "Finding dependencies: ")
+           self.verbose_logger.log(logginglevels.INFO_2, "Finding dependencies: ")
            try:
               return self.deplist()
            except yum.Errors.YumBaseError, e:
@@ -545,7 +521,7 @@
         elif self.basecmd in ['groupupdate', 'groupinstall', 'groupremove', 
                               'grouplist', 'groupinfo']:
 
-            self.log(2, "Setting up Group Process")
+            self.verbose_logger.log(logginglevels.INFO_2, "Setting up Group Process")
 
             self.doRepoSetup(dosack=0)
             try:
@@ -576,29 +552,29 @@
                     return 1, [str(e)]
             
         elif self.basecmd in ['search']:
-            self.log(2, "Searching Packages: ")
+            self.logger.debug("Searching Packages: ")
             try:
                 return self.search()
             except yum.Errors.YumBaseError, e:
                 return 1, [str(e)]
         
         elif self.basecmd in ['provides', 'whatprovides']:
-            self.log(2, "Searching Packages: ")
+            self.logger.debug("Searching Packages: ")
             try:
                 return self.provides()
             except yum.Errors.YumBaseError, e:
                 return 1, [str(e)]
 
         elif self.basecmd in ['resolvedep']:
-            self.log(2, "Searching Packages for Dependency:")
+            self.logger.debug("Searching Packages for Dependency:")
             try:
                 return self.resolveDepCli()
             except yum.Errors.YumBaseError, e:
                 return 1, [str(e)]
         
         elif self.basecmd in ['makecache']:
-            self.log(2, "Making cache files for all metadata files.")
-            self.log(2, "This may take a while depending on the speed of this computer")
+            self.logger.debug("Making cache files for all metadata files.")
+            self.logger.debug("This may take a while depending on the speed of this computer")
             try:
                 for repo in self.repos.findRepos('*'):
                     repo.metadata_expire = 0
@@ -619,7 +595,7 @@
            RUNNING the transaction"""
 
         # output what will be done:
-        self.log(1, self.listTransaction())
+        self.verbose_logger.log(logginglevels.INFO_1, self.listTransaction())
         
         # Check which packages have to be downloaded
         downloadpkgs = []
@@ -639,10 +615,10 @@
         # confirm with user
         if self._promptWanted():
             if not self.userconfirm():
-                self.log(0, 'Exiting on user Command')
+                self.verbose_logger.info('Exiting on user Command')
                 return 1
 
-        self.log(2, 'Downloading Packages:')
+        self.verbose_logger.log(logginglevels.INFO_2, 'Downloading Packages:')
         problems = self.downloadPkgs(downloadpkgs) 
 
         if len(problems.keys()) > 0:
@@ -658,7 +634,7 @@
         if self.gpgsigcheck(downloadpkgs) != 0:
             return 1
         
-        self.log(2, 'Running Transaction Test')
+        self.verbose_logger.log(logginglevels.INFO_2, 'Running Transaction Test')
         tsConf = {}
         for feature in ['diskspacecheck']: # more to come, I'm sure
             tsConf[feature] = getattr(self.conf, feature)
@@ -676,14 +652,14 @@
         tserrors = self.ts.test(testcb, conf=tsConf)
         del testcb
         
-        self.log(2, 'Finished Transaction Test')
+        self.verbose_logger.log(logginglevels.INFO_2, 'Finished Transaction Test')
         if len(tserrors) > 0:
             errstring = 'Transaction Check Error: '
             for descr in tserrors:
                 errstring += '  %s\n' % descr 
             
             raise yum.Errors.YumBaseError, errstring
-        self.log(2, 'Transaction Test Succeeded')
+        self.verbose_logger.log(logginglevels.INFO_2, 'Transaction Test Succeeded')
         del self.ts
         
         self.initActionTs() # make a new, blank ts to populate
@@ -698,14 +674,14 @@
         if self.conf.debuglevel < 2:
             output = 0
         cb = callback.RPMInstallCallback(output=output)
-        cb.filelog = self.filelog # needed for log file output
+        cb.filelog = logging.getLogger("yum.filelogging") # needed for log file output
         cb.tsInfo = self.tsInfo
 
-        self.log(2, 'Running Transaction')
+        self.verbose_logger.log(logginglevels.INFO_2, 'Running Transaction')
         self.runTransaction(cb=cb)
 
         # close things
-        self.log(1, self.postTransactionOutput())
+        self.verbose_logger.log(logginglevels.INFO_1, self.postTransactionOutput())
         return 0
         
     def gpgsigcheck(self, pkgs):
@@ -763,7 +739,8 @@
         toBeInstalled = {} # keyed on name
         passToUpdate = [] # list of pkgtups to pass along to updatecheck
 
-        self.log(2, _('Parsing package install arguments'))
+        self.verbose_logger.log(logginglevels.INFO_2,
+            _('Parsing package install arguments'))
         for arg in userlist:
             if os.path.exists(arg) and arg.endswith('.rpm'): # this is hurky, deal w/it
                 val, msglist = self.localInstall(filelist=[arg])
@@ -775,11 +752,12 @@
                                                                casematch=1)
             if len(unmatched) > 0: # if we get back anything in unmatched, check it for a virtual-provide
                 arg = unmatched[0] #only one in there
-                self.log(3, 'Checking for virtual provide or file-provide for %s' % arg)
+                self.verbose_logger.debug('Checking for virtual provide or file-provide for %s', 
+                    arg)
                 try:
                     mypkg = self.returnPackageByDep(arg)
                 except yum.Errors.YumBaseError, e:
-                    self.errorlog(0, _('No Match for argument: %s') % arg)
+                    self.logger.critical(_('No Match for argument: %s') % arg)
                 else:
                     arg = '%s:%s-%s-%s.%s' % (mypkg.epoch, mypkg.name,
                                               mypkg.version, mypkg.release,
@@ -795,7 +773,8 @@
             # ones that we obviously can't use
             for pkg in installable:
                 if pkg.pkgtup in installed:
-                    self.log(6, 'Package %s is already installed, skipping' % pkg)
+                    self.verbose_logger.log(logginglevels.DEBUG_3,
+                        'Package %s is already installed, skipping', pkg)
                     continue
                 
                 # everything installed that matches the name
@@ -806,7 +785,8 @@
                     if rpmUtils.arch.isMultiLibArch(a2) == rpmUtils.arch.isMultiLibArch(pkg.arch):
                         comparable.append(instTup)
                     else:
-                        self.log(6, 'Discarding non-comparable pkg %s.%s' % (n2, a2))
+                        self.verbose_logger.log(logginglevels.DEBUG_6,
+                            'Discarding non-comparable pkg %s.%s', n2, a2)
                         continue
                         
                 # go through each package 
@@ -831,7 +811,7 @@
                                 if not toBeInstalled.has_key(pkg.name): toBeInstalled[pkg.name] = []
                                 toBeInstalled[pkg.name].append(pkg)
                 else: # we've not got any installed that match n or n+a
-                    self.log(4, 'No other %s installed, adding to list for potential install' % pkg.name)
+                    self.verbose_logger.log(logginglevels.DEBUG_1, 'No other %s installed, adding to list for potential install', pkg.name)
                     if not toBeInstalled.has_key(pkg.name): toBeInstalled[pkg.name] = []
                     toBeInstalled[pkg.name].append(pkg)
         
@@ -846,16 +826,16 @@
         # is also an obsolete. if so then we need to mark it as such in the
         # tsInfo.
         if len(pkglist) > 0:
-            self.log(3, 'reduced installs :')
+            self.verbose_logger.debug('reduced installs :')
         for po in pkglist:
-            self.log(3,'   %s.%s %s:%s-%s' % po.pkgtup)
+            self.verbose_logger.debug('   %s.%s %s:%s-%s', po.pkgtup)
             self.install(po)
 
         if len(passToUpdate) > 0:
-            self.log(3, 'potential updates :')
+            self.verbose_logger.debug('potential updates :')
             updatelist = []
             for (n,a,e,v,r) in passToUpdate:
-                self.log(3, '   %s.%s %s:%s-%s' % (n, a, e, v, r))
+                self.verbose_logger.debug('   %s.%s %s:%s-%s', n, a, e, v, r)
                 pkgstring = '%s:%s-%s-%s.%s' % (e,n,v,r,a)
                 updatelist.append(pkgstring)
             self.updatePkgs(userlist=updatelist, quiet=1)
@@ -898,7 +878,7 @@
                 txmbrs = self.tsInfo.getMembers(pkgtup=old)
 
                 if txmbrs and txmbrs[0].output_state == TS_OBSOLETED: 
-                    self.log(5, 'Not Updating Package that is already obsoleted: %s.%s %s:%s-%s' % old)
+                    self.verbose_logger.log(logginglevels.DEBUG_2, 'Not Updating Package that is already obsoleted: %s.%s %s:%s-%s', old)
                 else:
                     updating_pkg = self.getPackageObject(new)
                     updated_pkg = YumInstalledPackage(self.rpmdb.returnHeaderByTuple(old)[0])
@@ -930,7 +910,7 @@
                                                 updatesPo, userlist, casematch=1)
             for userarg in unmatched:
                 if not quiet:
-                    self.errorlog(1, 'Could not find update match for %s' % userarg)
+                    self.logger.error('Could not find update match for %s' % userarg)
 
             updateMatches = yum.misc.unique(matched + exactmatch)
             for po in updateMatches:
@@ -975,11 +955,11 @@
                 try:
                     depmatches = self.returnInstalledPackagesByDep(arg)
                 except yum.Errors.YumBaseError, e:
-                    self.errorlog(0, _('%s') % e)
+                    self.logger.critical(_('%s') % e)
                     continue
                     
                 if not depmatches:
-                    self.errorlog(0, _('No Match for argument: %s') % arg)
+                    self.logger.critical(_('No Match for argument: %s') % arg)
                 else:
                     erases.extend(depmatches)
             
@@ -1019,16 +999,17 @@
             try:
                 po = YumLocalPackage(ts=self.read_ts, filename=pkg)
             except yum.Errors.MiscError, e:
-                self.errorlog(0, 'Cannot open file: %s. Skipping.' % pkg)
+                self.logger.critical('Cannot open file: %s. Skipping.', pkg)
                 continue
-            self.log(2, 'Examining %s: %s' % (po.localpath, po))
+            self.verbose_logger.log(logginglevels.INFO_2, 'Examining %s: %s', 
+                po.localpath, po)
 
             # everything installed that matches the name
             installedByKey = self.rpmdb.returnTupleByKeyword(name=po.name)
             # go through each package 
             if len(installedByKey) == 0: # nothing installed by that name
                 if updateonly:
-                    self.errorlog(2, 'Package %s not installed, cannot update it. Run yum install to install it instead.' % po.name)
+                    self.logger.warning('Package %s not installed, cannot update it. Run yum install to install it instead.', po.name)
                 else:
                     installpkgs.append(po)
                 continue
@@ -1066,24 +1047,27 @@
 
         for po in installpkgs:
             if po in toexc:
-               self.log(3, 'Excluding %s' % po)
+               self.verbose_logger.debug('Excluding %s', po)
                continue
             
-            self.log(2, 'Marking %s to be installed' % po.localpath)
+            self.verbose_logger.log(logginglevels.INFO_2, 'Marking %s to be installed',
+                po.localpath)
             self.localPackages.append(po)
             self.install(po=po)
         
         for (po, oldpo) in updatepkgs:
             if po in toexc:
-               self.log(3, 'Excluding %s' % po)
+               self.verbose_logger.debug('Excluding %s', po)
                continue
            
-            self.log(2, 'Marking %s as an update to %s' % (po.localpath, oldpo))
+            self.verbose_logger.log(logginglevels.INFO_2,
+                'Marking %s as an update to %s', po.localpath, oldpo)
             self.localPackages.append(po)
             self.tsInfo.addUpdate(po, oldpo)
         
         for po in donothingpkgs:
-            self.log(2, '%s: does not update installed package.' % po.localpath)
+            self.verbose_logger.log(logginglevels.INFO_2,
+                '%s: does not update installed package.', po.localpath)
 
         if len(self.tsInfo) > oldcount:
             return 2, ['Package(s) to install']
@@ -1119,7 +1103,8 @@
 
         def _shrinklist(lst, args):
             if len(lst) > 0 and len(args) > 0:
-                self.log(4, 'Matching packages for package list to user args')
+                self.verbose_logger.log(logginglevels.DEBUG_1,
+                    'Matching packages for package list to user args')
                 exactmatch, matched, unmatched = yum.packages.parsePackages(lst, args)
                 return yum.misc.unique(matched + exactmatch)
             else:
@@ -1134,7 +1119,7 @@
         
 #        for lst in [ypl.obsoletes, ypl.updates]:
 #            if len(lst) > 0 and len(self.extcmds) > 0:
-#                self.log(4, 'Matching packages for tupled package list to user args')
+#                self.logger.log(4, 'Matching packages for tupled package list to user args')
 #                for (pkg, instpkg) in lst:
 #                    exactmatch, matched, unmatched = yum.packages.parsePackages(lst, self.extcmds)
                     
@@ -1198,10 +1183,10 @@
             try:
                 pkg = self.returnPackageByDep(arg)
             except yum.Errors.YumBaseError, e:
-                self.errorlog(0, _('No Package Found for %s') % arg)
+                self.logger.critical(_('No Package Found for %s'), arg)
             else:
                 msg = '%s:%s-%s-%s.%s' % (pkg.epoch, pkg.name, pkg.version, pkg.release, pkg.arch)
-                self.log(0, msg)
+                self.verbose_logger.info(msg)
 
         return 0, []
     
@@ -1212,7 +1197,7 @@
         pkgresults = hdrresults = xmlresults = dbresults = []
 
         if 'all' in self.extcmds:
-            self.log(2, 'Cleaning up Everything')
+            self.verbose_logger.log(logginglevels.INFO_2, 'Cleaning up Everything')
             pkgcode, pkgresults = self.cleanPackages()
             hdrcode, hdrresults = self.cleanHeaders()
             xmlcode, xmlresults = self.cleanMetadata()
@@ -1222,30 +1207,30 @@
             code = hdrcode + pkgcode + xmlcode + dbcode
             results = hdrresults + pkgresults + xmlresults + dbresults
             for msg in results:
-                self.log(2, msg)
+                self.logger.debug(msg)
             return code, []
             
         if 'headers' in self.extcmds:
-            self.log(2, 'Cleaning up Headers')
+            self.logger.debug('Cleaning up Headers')
             hdrcode, hdrresults = self.cleanHeaders()
         if 'packages' in self.extcmds:
-            self.log(2, 'Cleaning up Packages')
+            self.logger.debug('Cleaning up Packages')
             pkgcode, pkgresults = self.cleanPackages()
         if 'metadata' in self.extcmds:
-            self.log(2, 'Cleaning up xml metadata')
+            self.logger.debug('Cleaning up xml metadata')
             xmlcode, xmlresults = self.cleanMetadata()
         if 'dbcache' in self.extcmds:
-            self.log(2, 'Cleaning up database cache')
+            self.logger.debug('Cleaning up database cache')
             dbcode, dbresults =  self.cleanSqlite()
         if 'plugins' in self.extcmds:
-            self.log(2, 'Cleaning up plugins')
+            self.logger.debug('Cleaning up plugins')
             self.plugins.run('clean')
 
             
         code = hdrcode + pkgcode + xmlcode + dbcode
         results = hdrresults + pkgresults + xmlresults + dbresults
         for msg in results:
-            self.log(2, msg)
+            self.verbose_logger.log(logginglevels.INFO_2, msg)
         return code, []
 
     def returnGroupLists(self, userlist=None):
@@ -1261,14 +1246,16 @@
         installed, available = self.doGroupLists(uservisible=uservisible)
 
         if len(installed) > 0:
-            self.log(2, 'Installed Groups:')
+            self.verbose_logger.log(logginglevels.INFO_2, 'Installed Groups:')
             for group in installed:
-                self.log(2, '   %s' % group.name)
+                self.verbose_logger.log(logginglevels.INFO_2, '   %s',
+                    group.name)
         
         if len(available) > 0:
-            self.log(2, 'Available Groups:')
+            self.verbose_logger.log(logginglevels.INFO_2, 'Available Groups:')
             for group in available:
-                self.log(2, '   %s' % group.name)
+                self.verbose_logger.log(logginglevels.INFO_2, '   %s',
+                    group.name)
 
             
         return 0, ['Done']
@@ -1283,7 +1270,7 @@
             if group:
                 self.displayPkgsInGroups(group)
             else:
-                self.errorlog(1, 'Warning: Group %s does not exist.' % strng)
+                self.logger.error('Warning: Group %s does not exist.', strng)
         
         return 0, []
         
@@ -1299,13 +1286,13 @@
         for group_string in grouplist:
             group = self.comps.return_group(group_string)
             if not group:
-                self.errorlog(0, _('Warning: Group %s does not exist.') % group)
+                self.logger.critical(_('Warning: Group %s does not exist.'), group)
                 continue
             
             try:
                 txmbrs = self.selectGroup(group.groupid)
             except yum.Errors.GroupsError, e:
-                self.errorlog(0, _('Warning: Group %s does not exist.') % group)
+                self.logger.critical(_('Warning: Group %s does not exist.'), group)
                 continue
             else:
                 pkgs_used.extend(txmbrs)
@@ -1328,7 +1315,7 @@
             try:
                 txmbrs = self.groupRemove(group_string)
             except yum.Errors.GroupsError, e:
-                self.errorlog(0, 'No group named %s exists' % group_string)
+                self.logger.critical('No group named %s exists', group_string)
                 continue
             else:
                 pkgs_used.extend(txmbrs)
@@ -1380,13 +1367,12 @@
 
     def __init__(self, base, **kwargs):
         OptionParser.__init__(self, **kwargs)
-        self.base = base
+        self.logger = logging.getLogger("yum.cli")
 
     def error(self, msg):
-        '''This method is overridden so that error output goes to errorlog
-        '''
+        '''This method is overridden so that error output goes to logger. '''
         self.print_usage()
-        self.base.errorlog(0, "Command line error: "+msg)
+        self.logger.critical("Command line error: %s", msg)
         sys.exit(1)
 
 

Index: output.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/output.py,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -r1.67 -r1.68
--- output.py	21 Jun 2006 17:07:44 -0000	1.67
+++ output.py	23 Jun 2006 14:26:17 -0000	1.68
@@ -21,6 +21,7 @@
 import os.path
 import sys
 import time
+import logging
 from i18n import _
 
 from urlgrabber.progress import TextMeter
@@ -32,9 +33,14 @@
     pass
 
 import yum.Errors
+from yum import logginglevels
 
 class YumOutput:
 
+    def __init__(self):
+        self.logger = logging.getLogger("yum.cli")
+        self.verbose_logger = logging.getLogger("yum.verbose.cli")
+    
     def printtime(self):
         months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
                   'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
@@ -46,8 +52,8 @@
     def failureReport(self, errobj):
         """failure output for failovers from urlgrabber"""
         
-        self.errorlog(1, '%s: %s' % (errobj.url, str(errobj.exception)))
-        self.errorlog(1, 'Trying other mirror.')
+        self.logger.error('%s: %s', errobj.url, str(errobj.exception))
+        self.logger.error('Trying other mirror.')
         raise errobj.exception
     
         
@@ -211,11 +217,11 @@
         return(format % (number, space, symbols[depth]))
 
     def matchcallback(self, po, values):
-        self.log(2, '\n\n')
+        self.verbose_logger.log(logginglevels.INFO_2, '\n\n')
         self.simpleList(po)
-        self.log(2, 'Matched from:')
+        self.verbose_logger.log(logginglevels.INFO_2, 'Matched from:')
         for item in values:
-            self.log(2, '%s' % item)
+            self.verbose_logger.log(logginglevels.INFO_2, '%s', item)
 
     def reportDownloadSize(self, packages):
         """Report the total download size for a set of packages"""
@@ -230,11 +236,12 @@
                 totsize += size
             except:
                  error = True
-                 self.errorlog(1, 'There was an error calculating total download size')
+                 self.logger.error('There was an error calculating total download size')
                  break
 
         if (not error):
-            self.log(1, "Total download size: %s" % (self.format_number(totsize)))
+            self.verbose_logger.log(logginglevels.INFO_1, "Total download size: %s", 
+                self.format_number(totsize))
             
     def listTransaction(self):
         """returns a string rep of the  transaction in an easy-to-read way."""
@@ -321,14 +328,13 @@
             self.repos.callback = None
         else:
             self.repos.setProgressBar(TextMeter(fo=sys.stdout))
-            self.repos.callback = CacheProgressCallback(self.log, self.errorlog,
-                                                        self.filelog)
+            self.repos.callback = CacheProgressCallback()
         # setup our failure report for failover
         freport = (self.failureReport,(),{})
         self.repos.setFailureCallback(freport)
         
         # setup our depsolve progress callback
-        dscb = DepSolveProgressCallBack(self.log, self.errorlog)
+        dscb = DepSolveProgressCallBack()
         self.dsCallback = dscb
             
     
@@ -336,10 +342,9 @@
 class DepSolveProgressCallBack:
     """provides text output callback functions for Dependency Solver callback"""
     
-    def __init__(self, log, errorlog):
+    def __init__(self):
         """requires yum-cli log and errorlog functions as arguments"""
-        self.log = log
-        self.errorlog = errorlog
+        self.verbose_logger = logging.getLogger("yum.verbose.cli")
         self.loops = 0
     
     def pkgAdded(self, pkgtup, mode):
@@ -349,39 +354,49 @@
                      'e': 'erased'}
         (n, a, e, v, r) = pkgtup
         modeterm = modedict[mode]
-        self.log(2, '---> Package %s.%s %s:%s-%s set to be %s' % (n, a, e, v, r, modeterm))
+        self.verbose_logger.log(logginglevels.INFO_2,
+            '---> Package %s.%s %s:%s-%s set to be %s', n, a, e, v, r,
+            modeterm)
         
     def start(self):
         self.loops += 1
         
     def tscheck(self):
-        self.log(2, '--> Running transaction check')
+        self.verbose_logger.log(logginglevels.INFO_2, '--> Running transaction check')
         
     def restartLoop(self):
         self.loops += 1
-        self.log(2, '--> Restarting Dependency Resolution with new changes.')
-        self.log(3, '---> Loop Number: %d' % self.loops)
+        self.verbose_logger.log(logginglevels.INFO_2,
+            '--> Restarting Dependency Resolution with new changes.')
+        self.verbose_logger.debug('---> Loop Number: %d', self.loops)
     
     def end(self):
-        self.log(2, '--> Finished Dependency Resolution')
+        self.verbose_logger.log(logginglevels.INFO_2,
+            '--> Finished Dependency Resolution')
 
     
     def procReq(self, name, formatted_req):
-        self.log(2, '--> Processing Dependency: %s for package: %s' % (formatted_req, name))
+        self.verbose_logger.log(logginglevels.INFO_2,
+            '--> Processing Dependency: %s for package: %s', formatted_req,
+            name)
         
     
     def unresolved(self, msg):
-        self.log(2, '--> Unresolved Dependency: %s' % msg)
+        self.verbose_logger.log(logginglevels.INFO_2, '--> Unresolved Dependency: %s',
+            msg)
 
     
     def procConflict(self, name, confname):
-        self.log(2, '--> Processing Conflict: %s conflicts %s' % (name, confname))
+        self.verbose_logger.log(logginglevels.INFO_2,
+            '--> Processing Conflict: %s conflicts %s', name, confname)
 
     def transactionPopulation(self):
-        self.log(2, '--> Populating transaction set with selected packages. Please wait.')
+        self.verbose_logger.log(logginglevels.INFO_2, '--> Populating transaction set '
+            'with selected packages. Please wait.')
     
     def downloadHeader(self, name):
-        self.log(2, '---> Downloading header for %s to pack into transaction set.' % name)
+        self.verbose_logger.log(logginglevels.INFO_2, '---> Downloading header for %s '
+            'to pack into transaction set.', name)
        
 
 class CacheProgressCallback:
@@ -390,21 +405,19 @@
     The class handles text output callbacks during metadata cache updates.
     '''
     
-    def __init__(self, log, errorlog, filelog=None):
-        self.log = log
-        self.errorlog = errorlog
-        self.filelog = filelog
+    def __init__(self):
+        self.logger = logging.getLogger("yum.cli")
+        self.verbose_logger = logging.getLogger("yum.verbose.cli")
+        self.file_logger = logging.getLogger("yum.filelogging.cli")
 
     def log(self, level, message):
-        self.log(level, message)
+        self.verbose_logger.log(level, message)
 
     def errorlog(self, level, message):
-        if self.errorlog:
-            self.errorlog(level, message)
+        self.logger.log(level, message)
 
     def filelog(self, level, message):
-        if self.filelog:
-            self.filelog(level, message)
+        self.file_logger.log(level, message)
 
     def progressbar(self, current, total, name=None):
         progressbar(current, total, name)

Index: shell.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/shell.py,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- shell.py	14 Mar 2006 22:19:18 -0000	1.28
+++ shell.py	23 Jun 2006 14:26:17 -0000	1.29
@@ -18,9 +18,11 @@
 import cmd
 import string
 import shlex
+import logging
 
 from yum import Errors
 from yum.constants import *
+import yum.logginglevels as logginglevels
 
 
 class YumShell(cmd.Cmd):
@@ -37,6 +39,8 @@
                 'run', 'ts', 'transaction', 'config']
                 
         self.commandlist = self.shell_specific_commands + self.base.yum_cli_commands
+        self.logger = logging.getLogger("yum.cli")
+        self.verbose_logger = logging.getLogger("yum.verbose.cli")
 
 
     def _shlex_split(self, input_string):
@@ -46,7 +50,7 @@
         try:
             inputs = shlex.split(input_string)
         except ValueError, e:
-            self.base.errorlog(0, 'Script Error: %s' % e)
+            self.logger.critical('Script Error: %s', e)
             if self.from_file:
                 raise Errors.YumBaseError, "Fatal error in script, exiting"
         
@@ -124,7 +128,7 @@
         else:
             self.base.usage()
         
-        self.base.log(0, msg)
+        self.verbose_logger.info(msg)
         
     def do_EOF(self, line):
         self.resultmsgs = ['Leaving Shell']
@@ -144,7 +148,8 @@
     def do_transaction(self, line):
         (cmd, args, line) = self.parseline(line)
         if cmd in ['list', None]:
-            self.base.log(2,self.base.listTransaction())
+            self.verbose_logger.log(logginglevels.INFO_2,
+                self.base.listTransaction())
         
         elif cmd == 'reset':
             self.base.closeRpmDB()
@@ -155,14 +160,15 @@
             try:
                 (code, msgs) = self.base.buildTransaction()
             except Errors.YumBaseError, e:
-                self.base.errorlog(0, 'Error building transaction: %s' % e)
+                self.logger.critical('Error building transaction: %s', e)
                 return False
                 
             if code == 1:
                 for msg in msgs:
-                    self.base.errorlog(0, 'Error: %s' % msg)
+                    self.logger.critical('Error: %s', msg)
             else:
-                self.base.log(2, 'Success resolving dependencies')
+                self.verbose_logger.log(logginglevels.INFO_2,
+                    'Success resolving dependencies')
                 
         elif cmd == 'run':
             return self.do_run('')
@@ -176,28 +182,30 @@
         if cmd in ['debuglevel', 'errorlevel']:
             opts = self._shlex_split(args)
             if not opts:
-                self.base.log(2, '%s: %s' % (cmd, getattr(self.base.conf, cmd)))
+                self.verbose_logger.log(logginglevels.INFO_2, '%s: %s', cmd,
+                    getattr(self.base.conf, cmd))
             else:
                 val = opts[0]
                 try:
                     val = int(val)
                 except ValueError, e:
-                    self.base.errorlog(0, 'Value %s for %s cannot be made to an int' % (val, cmd))
+                    self.logger.critical('Value %s for %s cannot be made to an int', val, cmd)
                     return
                 setattr(self.base.conf, cmd, val)
                 if cmd == 'debuglevel':
-                    self.base.log.threshold = val
+                    logginglevels.setDebugLevel(val)
                 elif cmd == 'errorlevel':
-                    self.base.errorlog.threshold = val
+                    logginglevels.setErrorLevel(val)
         # bools
         elif cmd in ['gpgcheck', 'obsoletes', 'assumeyes']:
             opts = self._shlex_split(args)
             if not opts:
-                self.base.log(2, '%s: %s' % (cmd, getattr(self.base.conf, cmd)))
+                self.verbose_logger.log(logginglevels.INFO_2, '%s: %s', cmd,
+                    getattr(self.base.conf, cmd))
             else:
                 value = opts[0]
                 if value.lower() not in BOOLEAN_STATES:
-                    self.base.errorlog(0, 'Value %s for %s is not a Boolean' % (value, cmd))
+                    self.logger.critical('Value %s for %s is not a Boolean', value, cmd)
                     return False
                 value = BOOLEAN_STATES[value.lower()]
                 setattr(self.base.conf, cmd, value)
@@ -211,7 +219,7 @@
             if not opts:
                 msg = '%s: ' % cmd
                 msg = msg + string.join(getattr(self.base.conf, cmd))
-                self.base.log(2, msg)
+                self.verbose_logger.log(logginglevels.INFO_2, msg)
                 return False
             else:
                 setattr(self.base.conf, cmd, opts)
@@ -233,15 +241,19 @@
     def do_repo(self, line):
         (cmd, args, line) = self.parseline(line)
         if cmd in ['list', None]:
+            format_string = "%-20.20s %-40.40s  %s"
             if self.base.repos.repos.values():
-                self.base.log(2, '%-20.20s %-40.40s  status' % ('repo id', 'repo name'))
+                self.verbose_logger.log(logginglevels.INFO_2, format_string,
+                    'repo id', 'repo name', 'status')
             repos = self.base.repos.repos.values()
             repos.sort()
             for repo in repos:
                 if repo in self.base.repos.listEnabled() and args in ('', 'enabled'):
-                    self.base.log(2, '%-20.20s %-40.40s  enabled' % (repo, repo.name))
+                    self.verbose_logger.log(logginglevels.INFO_2, format_string,
+                        repo, repo.name, 'enabled')
                 elif args in ('', 'disabled'):
-                    self.base.log(2, '%-20.20s %-40.40s  disabled' % (repo, repo.name))
+                    self.verbose_logger.log(logginglevels.INFO_2, format_string,
+                        repo, repo.name, 'disabled')
         
         elif cmd == 'enable':
             repos = self._shlex_split(args)
@@ -249,16 +261,16 @@
                 try:
                     changed = self.base.repos.enableRepo(repo)
                 except Errors.ConfigError, e:
-                    self.base.errorlog(0, e)
+                    self.logger.critical(e)
                 except Errors.RepoError, e:
-                    self.base.errorlog(0, e)
+                    self.logger.critical(e)
                     
                 else:
                     for repo in changed:
                         try:
                             self.base.doRepoSetup(thisrepo=repo)
                         except Errors.RepoError, e:
-                            self.base.errorlog(0, 'Disabling Repository')
+                            self.logger.critical('Disabling Repository')
                             self.base.repos.disableRepo(repo)
                             return False
                             
@@ -271,9 +283,9 @@
                 try:
                     self.base.repos.disableRepo(repo)
                 except Errors.ConfigError, e:
-                    self.base.errorlog(0, e)
+                    self.logger.critical(e)
                 except Errors.RepoError, e:
-                    self.base.errorlog(0, e)
+                    self.logger.critical(e)
 
                 else:
                     if hasattr(self.base, 'pkgSack'): # kill the pkgSack
@@ -301,22 +313,23 @@
                 (code, msgs) = self.base.buildTransaction()
                 if code == 1:
                     for msg in msgs:
-                        self.base.errorlog(0, 'Error: %s' % msg)
+                        self.logger.critical('Error: %s', msg)
                     return False
 
                 returnval = self.base.doTransaction()
             except Errors.YumBaseError, e:
-                self.base.errorlog(0, 'Error: %s' % e)
+                self.logger.critical('Error: %s', e)
             except KeyboardInterrupt, e:
-                self.base.errorlog(0, '\n\nExiting on user cancel')
+                self.logger.critical('\n\nExiting on user cancel')
             except IOError, e:
                 if e.errno == 32:
-                    self.base.errorlog(0, '\n\nExiting on Broken Pipe')
+                    self.logger.critical('\n\nExiting on Broken Pipe')
             else:
                 if returnval != 0:
-                    self.base.log(0, 'Transaction did not run.')
+                    self.verbose_logger.info('Transaction did not run.')
                 else:
-                    self.base.log(2, 'Finished Transaction')
+                    self.verbose_logger.log(logginglevels.INFO_2,
+                        'Finished Transaction')
                     self.base.closeRpmDB()
                     self.base.doTsSetup()
                     self.base.doRpmDBSetup()

Index: yummain.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yummain.py,v
retrieving revision 1.98
retrieving revision 1.99
diff -u -r1.98 -r1.99
--- yummain.py	3 Dec 2005 08:27:29 -0000	1.98
+++ yummain.py	23 Jun 2006 14:26:17 -0000	1.99
@@ -17,10 +17,12 @@
 
 import sys
 import locale
+import logging
 import time # test purposes only
 
 from yum import Errors
 from yum import plugins
+from yum import logginglevels
 import cli
 
 from i18n import _
@@ -31,13 +33,13 @@
     """This does all the real work"""
 
     def exUserCancel():
-        base.errorlog(0, '\n\nExiting on user cancel')
+        logger.critical('\n\nExiting on user cancel')
         unlock()
         sys.exit(1)
 
     def exIOError(e):
         if e.errno == 32:
-            base.errorlog(0, '\n\nExiting on Broken Pipe')
+            logger.critical('\n\nExiting on Broken Pipe')
         unlock()
         sys.exit(1)
 
@@ -48,12 +50,12 @@
         '''
         exitmsg = str(e)
         if exitmsg:
-            base.errorlog(2, '\n\n%s' % exitmsg)
+            logger.warn('\n\n%s', exitmsg)
         unlock()
         sys.exit(1)
 
     def exFatal(e):
-        base.errorlog(0, '\n\n%s' % str(e))
+        logger.critical('\n\n%s', str(e))
         unlock()
         sys.exit(1)
 
@@ -64,6 +66,9 @@
         except Errors.LockError, e:
             sys.exit(200)
 
+    logger = logging.getLogger("yum.main")
+    verbose_logger = logging.getLogger("yum.verbose.main")
+
     try:
         locale.setlocale(locale.LC_ALL, '')
     except locale.Error, e:
@@ -85,7 +90,7 @@
     try:
         base.doLock(YUM_PID_FILE)
     except Errors.LockError, e:
-        base.errorlog(0,'%s' % e.msg)
+        logger.critical('%s', e.msg)
         sys.exit(200)
 
     # build up an idea of what we're supposed to do
@@ -109,13 +114,13 @@
     if result == 0:
         # Normal exit 
         for msg in resultmsgs:
-            base.log(2, '%s' % msg)
+            verbose_logger.log(logginglevels.INFO_2, '%s', msg)
         unlock()
         sys.exit(0)
     elif result == 1:
         # Fatal error
         for msg in resultmsgs:
-            base.errorlog(0, 'Error: %s' % msg)
+            logger.critical('Error: %s', msg)
         unlock()
         sys.exit(1)
     elif result == 2:
@@ -125,15 +130,15 @@
         unlock()
         sys.exit(100)
     else:
-        base.errorlog(0, 'Unknown Error(s): Exit Code: %d:' % result)
+        logger.critical('Unknown Error(s): Exit Code: %d:', result)
         for msg in resultmsgs:
-            base.errorlog(0, msg)
+            logger.critical(msg)
         unlock()
         sys.exit(3)
             
     # Depsolve stage
-    base.log(2, 'Resolving Dependencies')
-    base.log(3, time.time())
+    verbose_logger.log(logginglevels.INFO_2, 'Resolving Dependencies')
+    verbose_logger.debug(time.time())
     try:
         (result, resultmsgs) = base.buildTransaction() 
     except plugins.PluginYumExit, e:
@@ -154,21 +159,21 @@
     elif result == 1:
         # Fatal error
         for msg in resultmsgs:
-            base.errorlog(0, 'Error: %s' % msg)
+            logger.critical('Error: %s', msg)
         unlock()
         sys.exit(1)
     elif result == 2:
         # Continue on
         pass
     else:
-        base.errorlog(0, 'Unknown Error(s): Exit Code: %d:' % result)
+        logger.critical('Unknown Error(s): Exit Code: %d:', result)
         for msg in resultmsgs:
-            base.errorlog(0, msg)
+            logger.critical(msg)
         unlock()
         sys.exit(3)
 
-    base.log(2, '\nDependencies Resolved')
-    base.log(3, time.time())
+    verbose_logger.log(logginglevels.INFO_2, '\nDependencies Resolved')
+    verbose_logger.debug(time.time())
 
     # Run the transaction
     try:
@@ -182,7 +187,7 @@
     except IOError, e:
         exIOError(e)
 
-    base.log(2, 'Complete!')
+    verbose_logger.log(logginglevels.INFO_2, 'Complete!')
     unlock()
     sys.exit(0)
 




More information about the Yum-cvs-commits mailing list