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:
Lubomír Sedlář 2016-11-04 09:01:58 +01:00 committed by Tester
parent 4a7257f550
commit ea1bcf625b

View File

@ -214,6 +214,7 @@ class Pungi(PungiBase):
lock = lockfile.LockFile(filename)
self.yumlock = ReentrantYumLock(lock, self.logger)
if not self.logger.handlers:
# Create the stdout/err streams and only send INFO+ stuff there
formatter = logging.Formatter('%(name)s:%(levelname)s: %(message)s')
console = logging.StreamHandler()