mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-01-03 01:18:00 +03:00
tests: abide logging options for clitests
We need to restore logging after calling the cli tools. Centralize the logging reset behavior since we need that too Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
parent
39366c37f6
commit
78ad233653
@ -14,7 +14,7 @@ os.environ.pop("_ARC_DEBUG", None)
|
||||
|
||||
# pylint: disable=wrong-import-position
|
||||
from virtinst import buildconfig
|
||||
from virtinst import log
|
||||
from virtinst import log, reset_logging
|
||||
# This sets all the cli bits back to their defaults
|
||||
imp.reload(buildconfig)
|
||||
|
||||
@ -28,9 +28,7 @@ virtxml = None
|
||||
|
||||
def setup_logging():
|
||||
import logging
|
||||
rootLogger = logging.getLogger()
|
||||
for handler in rootLogger.handlers:
|
||||
rootLogger.removeHandler(handler)
|
||||
reset_logging()
|
||||
|
||||
fmt = "%(levelname)-8s %(message)s"
|
||||
streamHandler = logging.StreamHandler()
|
||||
|
@ -21,6 +21,7 @@ from virtinst import log
|
||||
from virtinst import OSDB
|
||||
from virtinst.install import unattended
|
||||
|
||||
from tests import setup_logging
|
||||
from tests import virtinstall, virtclone, virtconvert, virtxml
|
||||
from tests import utils
|
||||
|
||||
@ -244,6 +245,8 @@ class Command(object):
|
||||
sys.argv = oldargv
|
||||
if oldenv:
|
||||
os.environ = oldenv
|
||||
# Reset logging
|
||||
setup_logging()
|
||||
|
||||
|
||||
def _get_output(self, conn):
|
||||
|
@ -65,4 +65,4 @@ from virtinst.snapshot import DomainSnapshot
|
||||
|
||||
from virtinst.connection import VirtinstConnection
|
||||
|
||||
from virtinst.logger import log
|
||||
from virtinst.logger import log, reset_logging
|
||||
|
@ -23,7 +23,7 @@ from .buildconfig import BuildConfig
|
||||
from .connection import VirtinstConnection
|
||||
from .devices import (Device, DeviceController, DeviceDisk, DeviceGraphics,
|
||||
DeviceInterface, DevicePanic)
|
||||
from .logger import log
|
||||
from .logger import log, reset_logging
|
||||
from .nodedev import NodeDevice
|
||||
from .osdict import OSDB
|
||||
from .storage import StoragePool, StorageVolume
|
||||
@ -119,6 +119,7 @@ def setupParser(usage, description, introspection_epilog=False):
|
||||
|
||||
|
||||
def earlyLogging():
|
||||
reset_logging()
|
||||
import logging
|
||||
logging.basicConfig(level=logging.DEBUG, format='%(message)s')
|
||||
|
||||
@ -159,14 +160,7 @@ def setupLogging(appname, debug_stdout, do_quiet, cli_app=True):
|
||||
|
||||
import logging
|
||||
import logging.handlers
|
||||
rootLogger = logging.getLogger()
|
||||
|
||||
# Undo early logging
|
||||
for handler in rootLogger.handlers:
|
||||
rootLogger.removeHandler(handler)
|
||||
# Undo any logging on our log handler. Needed for test suite
|
||||
for handler in log.handlers:
|
||||
log.removeHandler(handler)
|
||||
reset_logging()
|
||||
|
||||
log.setLevel(logging.DEBUG)
|
||||
if logfile:
|
||||
|
@ -7,3 +7,15 @@ import logging
|
||||
|
||||
# This is exported by virtinst/__init__.py
|
||||
log = logging.getLogger("virtinst")
|
||||
|
||||
|
||||
def reset_logging():
|
||||
rootLogger = logging.getLogger()
|
||||
|
||||
# Undo early logging
|
||||
for handler in rootLogger.handlers:
|
||||
rootLogger.removeHandler(handler)
|
||||
|
||||
# Undo any logging on our log handler. Needed for test suite
|
||||
for handler in log.handlers:
|
||||
log.removeHandler(handler)
|
||||
|
Loading…
Reference in New Issue
Block a user