]> git.proxmox.com Git - mirror_qemu.git/commitdiff
qemu.py: Call logging.basicConfig() automatically
authorEduardo Habkost <ehabkost@redhat.com>
Thu, 21 Sep 2017 16:22:34 +0000 (13:22 -0300)
committerEduardo Habkost <ehabkost@redhat.com>
Fri, 22 Sep 2017 14:39:17 +0000 (11:39 -0300)
Not all scripts using qemu.py configure the Python logging
module, and end up generating a "No handlers could be found for
logger" message instead of actual log messages.

To avoid requiring every script using qemu.py to configure
logging manually, call basicConfig() when creating a QEMUMachine
object.  This won't affect scripts that already set up logging,
but will ensure that scripts that don't configure logging keep
working.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Fixes: 4738b0a85a0c2031fddc71b51cccebce0c4ba6b1
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Message-Id: <20170921162234.847-1-ehabkost@redhat.com>
Reviewed-by: Cleber Rosa <crosa@redhat.com>
Acked-by: Lukáš Doktor <ldoktor@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
scripts/qemu.py

index 5e02dd8e78775232abce925460de73bf7e6dae5a..73d6031e028cc2bf9a3c755b163182a4f720b4e7 100644 (file)
@@ -89,6 +89,9 @@ class QEMUMachine(object):
         self._qmp = None
         self._qemu_full_args = None
 
+        # just in case logging wasn't configured by the main script:
+        logging.basicConfig(level=(logging.DEBUG if debug else logging.WARN))
+
     def __enter__(self):
         return self