pungi: Only add logger once
The Pungi object reuses the same logger for all its instances. Every time a new instance is created, a stream handler would be added. This means that a second instance will print everything twice. When running tests, tens of instances would be created. This patch only adds the handler if there are no handlers configured yet. Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
4a7257f550
commit
ea1bcf625b
@ -214,12 +214,13 @@ class Pungi(PungiBase):
|
|||||||
lock = lockfile.LockFile(filename)
|
lock = lockfile.LockFile(filename)
|
||||||
self.yumlock = ReentrantYumLock(lock, self.logger)
|
self.yumlock = ReentrantYumLock(lock, self.logger)
|
||||||
|
|
||||||
# Create the stdout/err streams and only send INFO+ stuff there
|
if not self.logger.handlers:
|
||||||
formatter = logging.Formatter('%(name)s:%(levelname)s: %(message)s')
|
# Create the stdout/err streams and only send INFO+ stuff there
|
||||||
console = logging.StreamHandler()
|
formatter = logging.Formatter('%(name)s:%(levelname)s: %(message)s')
|
||||||
console.setFormatter(formatter)
|
console = logging.StreamHandler()
|
||||||
console.setLevel(logging.INFO)
|
console.setFormatter(formatter)
|
||||||
self.logger.addHandler(console)
|
console.setLevel(logging.INFO)
|
||||||
|
self.logger.addHandler(console)
|
||||||
|
|
||||||
self.destdir = self.config.get('pungi', 'destdir')
|
self.destdir = self.config.get('pungi', 'destdir')
|
||||||
self.archdir = os.path.join(self.destdir,
|
self.archdir = os.path.join(self.destdir,
|
||||||
|
Loading…
Reference in New Issue
Block a user