mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-01-07 14:43:01 -06: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
|
# pylint: disable=wrong-import-position
|
||||||
from virtinst import buildconfig
|
from virtinst import buildconfig
|
||||||
from virtinst import log
|
from virtinst import log, reset_logging
|
||||||
# This sets all the cli bits back to their defaults
|
# This sets all the cli bits back to their defaults
|
||||||
imp.reload(buildconfig)
|
imp.reload(buildconfig)
|
||||||
|
|
||||||
@ -28,9 +28,7 @@ virtxml = None
|
|||||||
|
|
||||||
def setup_logging():
|
def setup_logging():
|
||||||
import logging
|
import logging
|
||||||
rootLogger = logging.getLogger()
|
reset_logging()
|
||||||
for handler in rootLogger.handlers:
|
|
||||||
rootLogger.removeHandler(handler)
|
|
||||||
|
|
||||||
fmt = "%(levelname)-8s %(message)s"
|
fmt = "%(levelname)-8s %(message)s"
|
||||||
streamHandler = logging.StreamHandler()
|
streamHandler = logging.StreamHandler()
|
||||||
|
@ -21,6 +21,7 @@ from virtinst import log
|
|||||||
from virtinst import OSDB
|
from virtinst import OSDB
|
||||||
from virtinst.install import unattended
|
from virtinst.install import unattended
|
||||||
|
|
||||||
|
from tests import setup_logging
|
||||||
from tests import virtinstall, virtclone, virtconvert, virtxml
|
from tests import virtinstall, virtclone, virtconvert, virtxml
|
||||||
from tests import utils
|
from tests import utils
|
||||||
|
|
||||||
@ -244,6 +245,8 @@ class Command(object):
|
|||||||
sys.argv = oldargv
|
sys.argv = oldargv
|
||||||
if oldenv:
|
if oldenv:
|
||||||
os.environ = oldenv
|
os.environ = oldenv
|
||||||
|
# Reset logging
|
||||||
|
setup_logging()
|
||||||
|
|
||||||
|
|
||||||
def _get_output(self, conn):
|
def _get_output(self, conn):
|
||||||
|
@ -65,4 +65,4 @@ from virtinst.snapshot import DomainSnapshot
|
|||||||
|
|
||||||
from virtinst.connection import VirtinstConnection
|
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 .connection import VirtinstConnection
|
||||||
from .devices import (Device, DeviceController, DeviceDisk, DeviceGraphics,
|
from .devices import (Device, DeviceController, DeviceDisk, DeviceGraphics,
|
||||||
DeviceInterface, DevicePanic)
|
DeviceInterface, DevicePanic)
|
||||||
from .logger import log
|
from .logger import log, reset_logging
|
||||||
from .nodedev import NodeDevice
|
from .nodedev import NodeDevice
|
||||||
from .osdict import OSDB
|
from .osdict import OSDB
|
||||||
from .storage import StoragePool, StorageVolume
|
from .storage import StoragePool, StorageVolume
|
||||||
@ -119,6 +119,7 @@ def setupParser(usage, description, introspection_epilog=False):
|
|||||||
|
|
||||||
|
|
||||||
def earlyLogging():
|
def earlyLogging():
|
||||||
|
reset_logging()
|
||||||
import logging
|
import logging
|
||||||
logging.basicConfig(level=logging.DEBUG, format='%(message)s')
|
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
|
||||||
import logging.handlers
|
import logging.handlers
|
||||||
rootLogger = logging.getLogger()
|
reset_logging()
|
||||||
|
|
||||||
# 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)
|
|
||||||
|
|
||||||
log.setLevel(logging.DEBUG)
|
log.setLevel(logging.DEBUG)
|
||||||
if logfile:
|
if logfile:
|
||||||
|
@ -7,3 +7,15 @@ import logging
|
|||||||
|
|
||||||
# This is exported by virtinst/__init__.py
|
# This is exported by virtinst/__init__.py
|
||||||
log = logging.getLogger("virtinst")
|
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