diff --git a/examples/tests/guest_hostname.py b/examples/tests/guest_hostname.py index 3b9d66c084..fb5ebaf0db 100644 --- a/examples/tests/guest_hostname.py +++ b/examples/tests/guest_hostname.py @@ -7,6 +7,9 @@ import logging +LOG = logging.getLogger('avocado.vt.examples.guest_hostname') + + def run(test, params, env): """ Logs guest's hostname. @@ -30,4 +33,4 @@ def run(test, params, env): output = session.cmd_output("hostname") # 4) log the output - logging.info("The output of 'hostname' command from guest is '%s'", output) + LOG.info("The output of 'hostname' command from guest is '%s'", output) diff --git a/examples/tests/hostname.py b/examples/tests/hostname.py index 0d32f45a63..82531a071f 100644 --- a/examples/tests/hostname.py +++ b/examples/tests/hostname.py @@ -11,6 +11,9 @@ from avocado.utils import process +LOG = logging.getLogger('avocado.vt.examples.hostname') + + def run(test, params, env): """ Logs the host name and exits @@ -20,5 +23,5 @@ def run(test, params, env): :param env: Dictionary with test environment. """ result = process.run("hostname") - logging.info("Output of 'hostname' cmd is '%s'", - result.stdout_text) + LOG.info("Output of 'hostname' cmd is '%s'", + result.stdout_text) diff --git a/examples/tests/ls_disk.py b/examples/tests/ls_disk.py index bfcc5d8d3f..0022964ec0 100644 --- a/examples/tests/ls_disk.py +++ b/examples/tests/ls_disk.py @@ -15,6 +15,9 @@ import logging +LOG = logging.getLogger('avocado.vt.examples.lsdisk') + + def run(test, params, env): """ Logs guest's disk partitions @@ -26,7 +29,7 @@ def run(test, params, env): vm = env.get_vm(params["main_vm"]) session = vm.wait_for_login() output = session.cmd_output("ls /dev/[hsv]d* -1") - logging.info("Guest disks are:\n%s", output) + LOG.info("Guest disks are:\n%s", output) # Let's get some monitor data monitor = vm.monitor @@ -35,4 +38,4 @@ def run(test, params, env): # output = monitor.info("block", debug=False) # Following command unifies the response no matter which monitor is used output = monitor.info_block(debug=False) - logging.info("info block:\n%s", output) + LOG.info("info block:\n%s", output) diff --git a/examples/tests/service.py b/examples/tests/service.py index 83e79be512..b9489156c7 100644 --- a/examples/tests/service.py +++ b/examples/tests/service.py @@ -17,6 +17,9 @@ from virttest import error_context +LOG = logging.getLogger('avocado.vt.examples.service') + + # error_context.context_aware decorator initializes context, which provides additional # information on exceptions. @error_context.context_aware @@ -37,29 +40,29 @@ def run(test, params, env): if params.get('test_on_guest') == "yes": # error_context.context() is common method to log test steps used to verify # what exactly was tested. - error_context.context("Using guest.", logging.info) + error_context.context("Using guest.", LOG.info) vm = env.get_vm(params["main_vm"]) session = vm.wait_for_login() # RemoteRunner is object, which simulates the utils.run() behavior # on remote consoles runner = remote.RemoteRunner(session=session).run else: - error_context.context("Using host", logging.info) + error_context.context("Using host", LOG.info) runner = process.run - error_context.context("Initialize service manager", logging.info) + error_context.context("Initialize service manager", LOG.info) service = SpecificServiceManager(params["test_service"], runner) error_context.context("Testing service %s" % - params["test_service"], logging.info) + params["test_service"], LOG.info) original_status = service.status() - logging.info("Original status=%s", original_status) + LOG.info("Original status=%s", original_status) if original_status is True: service.stop() time.sleep(5) if service.status() is not False: - logging.error("Fail to stop service") + LOG.error("Fail to stop service") service.start() raise exceptions.TestFail("Fail to stop service") service.start() @@ -67,7 +70,7 @@ def run(test, params, env): service.start() time.sleep(5) if service.status() is not True: - logging.error("Fail to start service") + LOG.error("Fail to start service") service.stop() raise exceptions.TestFail("Fail to start service") service.start() diff --git a/examples/tests/template.py b/examples/tests/template.py index 8739c7ecc7..7d4738938f 100644 --- a/examples/tests/template.py +++ b/examples/tests/template.py @@ -4,6 +4,9 @@ import logging +LOG = logging.getLogger('avocado.test') + + def run(test, params, env): """ Docstring describing template. @@ -23,4 +26,4 @@ def run(test, params, env): timeout = float(params.get("login_timeout", 240)) session = vm.wait_for_login(timeout=timeout) uptime = session.cmd("uptime") - logging.info("Guest uptime result is: %s", uptime) + LOG.info("Guest uptime result is: %s", uptime)