From 6612ec39ba4f1a7f44780501197cd6b3e8832bc3 Mon Sep 17 00:00:00 2001 From: Jesse Keating Date: Fri, 17 Aug 2007 09:14:18 -0400 Subject: [PATCH] Move the stream handler to be in the named loggers, not the root logger This prevents double messages to the stream coming from Pungi. --- pypungi/__init__.py | 6 ------ pypungi/gather.py | 7 +++++++ pypungi/pungi.py | 7 +++++++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/pypungi/__init__.py b/pypungi/__init__.py index 931c23e6..32fdcd95 100644 --- a/pypungi/__init__.py +++ b/pypungi/__init__.py @@ -48,9 +48,3 @@ class PungiBase(): format='%(name)s.%(levelname)s: %(message)s', filename=logfile) - # Create the stdout/err streams and only send INFO+ stuff there - formatter = logging.Formatter('%(name)s:%(levelname)s: %(message)s') - console = logging.StreamHandler() - console.setFormatter(formatter) - console.setLevel(logging.INFO) - logging.getLogger('').addHandler(console) diff --git a/pypungi/gather.py b/pypungi/gather.py index be1d4790..157b527c 100755 --- a/pypungi/gather.py +++ b/pypungi/gather.py @@ -53,6 +53,13 @@ class Gather(pypungi.PungiBase): # Set our own logging name space self.logger = logging.getLogger('Pungi.Gather') + # Create the stdout/err streams and only send INFO+ stuff there + formatter = logging.Formatter('%(name)s:%(levelname)s: %(message)s') + console = logging.StreamHandler() + console.setFormatter(formatter) + console.setLevel(logging.INFO) + self.logger.addHandler(console) + self.pkglist = pkglist self.config.cachedir = os.path.join(self.workdir, 'yumcache') self.polist = [] diff --git a/pypungi/pungi.py b/pypungi/pungi.py index 3ffb84c1..f82d0306 100755 --- a/pypungi/pungi.py +++ b/pypungi/pungi.py @@ -28,6 +28,13 @@ class Pungi(pypungi.PungiBase): self.logger = logging.getLogger('Pungi.Pungi') + # Create the stdout/err streams and only send INFO+ stuff there + formatter = logging.Formatter('%(name)s:%(levelname)s: %(message)s') + console = logging.StreamHandler() + console.setFormatter(formatter) + console.setLevel(logging.INFO) + self.logger.addHandler(console) + self.prodpath = 'Fedora' # Probably should be defined elsewhere self.destdir = self.config.get('default', 'destdir') self.archdir = os.path.join(self.destdir,