diff -ur -x .hg pungi/pungi pungi_l/pungi
--- pungi/pungi	2007-05-28 14:54:05.000000000 +0200
+++ pungi_l/pungi	2007-05-29 13:59:49.000000000 +0200
@@ -83,6 +83,15 @@
 
     destdir = config.get('default', 'destdir')
 
+    if not config.has_option('default', 'quiet'):logF=True
+    else:logF=False
+    config.set('default','quiet',str(not logF))
+    
+    # change logging defaults. 
+    logPath = os.path.join(config.get('default', 'destdir'), 
+        'logs/%s.%s.log' % (config.get('default', 'flavor'), config.get('default', 'arch')))
+    pypungi.pungiLogO.changeDefaults(logPath=logPath, logF=logF)
+
     if not os.path.exists(destdir):
         try:
             os.makedirs(destdir)
diff -ur -x .hg pungi/pypungi/gather.py pungi_l/pypungi/gather.py
--- pungi/pypungi/gather.py	2007-05-28 12:49:57.000000000 +0200
+++ pungi_l/pypungi/gather.py	2007-05-29 13:49:41.000000000 +0200
@@ -49,7 +49,6 @@
         #self.doSackSetup(arches)
         self.doSackSetup(archlist=arches) # work around temp break in yum api
         self.doSackFilelistPopulate()
-        self.logger = yum.logging.getLogger("yum.verbose.pungi")
         self.pkglist = pkglist
         self.polist = []
         self.srpmlist = []
@@ -59,15 +58,8 @@
         self.compsobj.add(self.config.get('default', 'comps'))
 
     def doLoggingSetup(self, debuglevel, errorlevel):
-        """Setup the logging facility."""
-
-
-        logdir = os.path.join(self.config.get('default', 'destdir'), 'logs')
-        if not os.path.exists(logdir):
-            os.makedirs(logdir)
-        logfile = os.path.join(logdir, '%s.%s.log' % (self.config.get('default', 'flavor'),
-                                                      self.config.get('default', 'arch')))
-        yum.logging.basicConfig(level=yum.logging.DEBUG, filename=logfile)
+        # We want to use our own logger.
+        pass
 
     def doFileLogSetup(self, uid, logfile):
         # This function overrides a yum function, allowing pungi to control
@@ -95,8 +87,7 @@
            transaction info"""
 
 
-        if not self.config.has_option('default', 'quiet'):
-            self.logger.info('Checking deps of %s.%s' % (po.name, po.arch))
+        Plog.info('Checking deps of %s.%s' % (po.name, po.arch))
 
         reqs = po.requires
         provs = po.provides
@@ -112,13 +103,12 @@
 
             deps = self.whatProvides(r, f, v).returnPackages()
             if deps is None:
-                self.logger.warning("Unresolvable dependency %s in %s.%s" % (r, po.name, po.arch))
+                Plog.warning("Unresolvable dependency %s in %s.%s" % (r, po.name, po.arch))
                 continue
 
             for dep in deps:
                 self.tsInfo.addInstall(dep)
-                if not self.config.has_option('default', 'quiet'):
-                    self.logger.info('Added %s.%s for %s.%s' % (dep.name, dep.arch, po.name, po.arch))
+                Plog.info('Added %s.%s for %s.%s' % (dep.name, dep.arch, po.name, po.arch))
            
             self.resolved_deps[req] = None
 
@@ -143,7 +133,7 @@
 
         # Check if we have the group
         if not self.compsobj.has_group(group):
-            self.logger.error("Group %s not found in comps!" % group)
+            Plog.error("Group %s not found in comps!" % group)
             return packages
 
         # Get the group object to work with
@@ -194,22 +184,18 @@
         for line in self.pkglist:
             line = line.strip()
             if line.startswith('#'):
-                if not self.config.has_option('default', 'quiet'):
-                    self.logger.info('Skipping comment: %s' % line)
+                Plog.info('Skipping comment: %s' % line)
                 continue
             if line.startswith('@'):
-                if not self.config.has_option('default', 'quiet'):
-                    self.logger.info('Adding group: %s' % line)
+                Plog.info('Adding group: %s' % line)
                 grouplist.append(line.strip('@'))
                 continue
             if line.startswith('-'):
-                if not self.config.has_option('default', 'quiet'):
-                    self.logger.info('Adding exclude: %s' % line)
+                Plog.info('Adding exclude: %s' % line)
                 excludelist.append(line.strip('-'))
                 continue
             else:
-                if not self.config.has_option('default', 'quiet'):
-                    self.logger.info('Adding package: %s' % line)
+                Plog.info('Adding package: %s' % line)
                 addlist.append(line)
 
         # First remove the excludes
@@ -238,12 +224,10 @@
         mysack = yum.packageSack.ListPackageSack(matches)
         for match in mysack.returnNewestByNameArch():
             self.tsInfo.addInstall(match)
-            if not self.config.has_option('default', 'quiet'):
-                self.logger.info('Found %s.%s' % (match.name, match.arch))
+            Plog.info('Found %s.%s' % (match.name, match.arch))
 
         for pkg in unmatched:
-            if not pkg in matchdict.keys():
-                self.logger.warn('Could not find a match for %s' % pkg)
+            Plog.warn('Could not find a match for %s' % pkg)
 
         if len(self.tsInfo) == 0:
             raise yum.Errors.MiscError, 'No packages found to download.'
@@ -281,7 +265,7 @@
             for pkg in self.polist:
                 downloads.append('%s.%s' % (pkg.name, pkg.arch))
                 downloads.sort()
-            self.logger.info("Download list: %s" % downloads)
+            Plog.info("Download list: %s" % downloads)
 
         # Package location within destdir, name subject to change/config
         pkgdir = os.path.join(self.config.get('default', 'destdir'), self.config.get('default', 'version'), 
@@ -300,8 +284,7 @@
             local = os.path.join(self.config.get('default', 'cachedir'), local)
             if os.path.exists(local) and self.verifyCachePkg(pkg, local):
 
-                if not self.config.has_option('default', 'quiet'):
-                    self.logger.info("%s already exists and appears to be complete" % local)
+                Plog.info("%s already exists and appears to be complete" % local)
                 target = os.path.join(pkgdir, os.path.basename(remote))
                 if os.path.exists(target):
                     os.remove(target) # avoid traceback after interrupted download
@@ -310,8 +293,7 @@
 
             # Disable cache otherwise things won't download
             repo.cache = 0
-            if not self.config.has_option('default', 'quiet'):
-                self.logger.info('Downloading %s' % os.path.basename(remote))
+            Plog.info('Downloading %s' % os.path.basename(remote))
             pkg.localpath = local # Hack: to set the localpath to what we want.
 
             # do a little dance for file:// repos...
@@ -365,20 +347,17 @@
             local = os.path.basename(remote)
             local = os.path.join(self.config.get('default', 'cachedir'), local)
             if os.path.exists(local) and self.verifyCachePkg(pkg, local):
-
-                if not self.config.has_option('default', 'quiet'):
-                    self.logger.info("%s already exists and appears to be complete" % local)
-                if os.path.exists(os.path.join(pkgdir, os.path.basename(remote))) and self.verifyCachePkg(pkg, os.path.join(pkgdir, os.path.basename(remote))) == pkg.packagesize:
-                    if not self.config.has_option('default', 'quiet'):
-                        self.logger.info("%s already exists in tree and appears to be complete" % local)
+                Plog.info("%s already exists and appears to be complete" % local)
+                if os.path.exists(os.path.join(pkgdir, os.path.basename(remote))) and \
+                        self.verifyCachePkg(pkg, os.path.join(pkgdir, os.path.basename(remote))) == pkg.packagesize:
+                    Plog.info("%s already exists in tree and appears to be complete" % local)
                 else:
                     os.link(local, os.path.join(pkgdir, os.path.basename(remote)))
                 continue
 
             # Disable cache otherwise things won't download
             repo.cache = 0
-            if not self.config.has_option('default', 'quiet'):
-                self.logger.info('Downloading %s' % os.path.basename(remote))
+            Plog.info('Downloading %s' % os.path.basename(remote))
             pkg.localpath = local # Hack: to set the localpath to what we want.
 
             # do a little dance for file:// repos...
diff -ur -x .hg pungi/pypungi/__init__.py pungi_l/pypungi/__init__.py
--- pungi/pypungi/__init__.py	2007-05-28 12:49:57.000000000 +0200
+++ pungi_l/pypungi/__init__.py	2007-05-29 13:28:07.000000000 +0200
@@ -0,0 +1,69 @@
+#!/usr/bin/python -tt
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Library General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+
+
+import logging
+import os.path
+import os
+import __builtin__
+
+class PungiLog:
+    """Class to manage the pungi log
+    
+    Once the pypungi module is imported the class is initialized with default values.
+    The user can use it just by typing Plog.####("message").  This will automatically
+    log stuff to the default file.
+    If the user wants to change the defaults he must call the pypungi.pungiLogO.chengeDefaults.
+    """
+
+    __logPath="/srv/pungi/pungi.log"
+    __logF=True
+    __level=logging.DEBUG
+    def __init__(self, logPath=__logPath, logF=__logF, level=__level):
+        """ Initialize the logger.
+    
+        logPath - is the path to the file.
+        logF - when true log will be activated.
+        level - the level of debuging
+        """
+
+        self.createLogger(logPath, logF, level)
+        __builtin__.Plog = self.log
+
+    def changeDefaults(self, logPath=__logPath, logF=__logF, level=__level):
+        # remove all trace from previous filehandler.
+        self.log.removeHandler(self.fileHandler)
+        if logPath != self.__logPath : os.remove(self.__logPath)
+        self.createLogger(logPath, logF, level)
+
+        __builtin__.Plog = self.log
+
+    def createLogger(self, logPath, logF, level):
+        self.log = logging.getLogger("pungi")
+        if logF:
+            if not os.path.exists(os.path.split(logPath)[0]):
+                os.makedirs(os.path.split(logPath)[0])
+            self.fileHandler = logging.FileHandler(logPath)
+            self.fileHandler.setLevel(level)
+            
+            formatter = logging.Formatter('%(name)s-%(levelno)s-%(funcName)s : %(message)s')
+            self.fileHandler.setFormatter(formatter)
+        
+            self.log.addHandler(self.fileHandler) 
+            self.log.setLevel(logging.DEBUG)
+        else:
+            self.log.disabled=1
+ 
+pungiLogO = PungiLog()#Pungi log object
diff -ur -x .hg pungi/pypungi/pungi.py pungi_l/pypungi/pungi.py
--- pungi/pypungi/pungi.py	2007-05-28 12:49:57.000000000 +0200
+++ pungi_l/pypungi/pungi.py	2007-05-29 13:49:39.000000000 +0200
@@ -13,7 +13,6 @@
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 import subprocess
-import logging
 import os
 import sys
 sys.path.append('/usr/lib/anaconda-runtime')
@@ -21,8 +20,6 @@
 import shutil
 import re
 
-log = logging.getLogger("pypungi.pungi")
-
 class Pungi:
     def __init__(self, config):
         self.config = config
@@ -67,16 +64,16 @@
         """Run a command and log the output.  Error out if we get something on stderr"""
 
 
-        log.info("Running %s" % ' '.join(command))
+        Plog.info("Running %s" % ' '.join(command))
 
         p1 = subprocess.Popen(command, cwd=rundir, stdout=output, stderr=error)
         (out, err) = p1.communicate()
         if p1.returncode != 0:
-            log.error("Got an error from %s" % command[0])
-            log.error(err)
+            Plog.error("Got an error from %s" % command[0])
+            Plog.error(err)
             raise OSError, "Got an error from %s" % command[0]
 
-        log.info(out)
+        Plog.info(out)
 
     def doBuildinstall(self):
         """Run anaconda-runtime's buildinstall on the tree."""
@@ -180,18 +177,18 @@
                         (out, err) = subprocess.Popen(cpio, cwd=docsdir, stdin=p1.stdout, stdout=subprocess.PIPE, 
                             stderr=subprocess.PIPE).communicate()
                     except:
-                        log.error("Got an error from rpm2cpio")
-                        log.error(err)
+                        Plog.error("Got an error from rpm2cpio")
+                        Plog.error(err)
                         raise
 
-                    log.info(out)
+                    Plog.info(out)
 
         # Walk the tree for our files
         for dirpath, dirname, filelist in os.walk(docsdir):
             for filename in filelist:
                 for regex in fileres:
                     if regex.match(filename) and not os.path.exists(os.path.join(self.topdir, filename)):
-                        log.info("Copying release note file %s" % filename)
+                        Plog.info("Copying release note file %s" % filename)
                         shutil.copy(os.path.join(dirpath, filename), os.path.join(self.topdir, filename))
                         self.common_files.append(filename)
 
@@ -200,7 +197,7 @@
             for directory in dirname:
                 for regex in dirres:
                     if regex.match(directory) and not os.path.exists(os.path.join(self.topdir, directory)):
-                        log.info("Copying release note dir %s" % directory)
+                        Plog.info("Copying release note dir %s" % directory)
                         shutil.copytree(os.path.join(dirpath, directory), os.path.join(self.topdir, directory))
         
 
@@ -228,7 +225,7 @@
         #timber.reserve_size =  
 
         output = timber.main()
-        log.info("Output from splittree: %s" % '\n'.join(output))
+        Plog.info("Output from splittree: %s" % '\n'.join(output))
 
     def doSplitSRPMs(self):
         """Use anaconda-runtime's splittree to split the srpms into appropriate
@@ -266,7 +263,7 @@
                                timber.common_files)
 
         timber.splitSRPMS()
-        log.info("splitSRPMS complete")
+        Plog.info("splitSRPMS complete")
 
     def doCreateSplitrepo(self):
         """Create the split metadata for the isos"""
@@ -514,4 +511,4 @@
             if directory.startswith('os-disc') or directory.startswith('SRPM-disc'):
                 shutil.move(os.path.join(self.archdir, directory), os.path.join(self.workdir, directory))
 
-        log.info("CreateIsos is done.")
+        Plog.info("CreateIsos is done.")
