From patchwork Thu Sep 21 16:22:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 817007 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xyhk45vxjz9t4B for ; Fri, 22 Sep 2017 02:23:24 +1000 (AEST) Received: from localhost ([::1]:54564 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dv4G2-00045Q-Ri for incoming@patchwork.ozlabs.org; Thu, 21 Sep 2017 12:23:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55053) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dv4FS-000455-HJ for qemu-devel@nongnu.org; Thu, 21 Sep 2017 12:22:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dv4FO-0003ik-By for qemu-devel@nongnu.org; Thu, 21 Sep 2017 12:22:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56216) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dv4FO-0003ge-67 for qemu-devel@nongnu.org; Thu, 21 Sep 2017 12:22:42 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 90989806CB; Thu, 21 Sep 2017 16:22:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 90989806CB Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=ehabkost@redhat.com Received: from localhost (ovpn-116-204.phx2.redhat.com [10.3.116.204]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2BDDB5EE06; Thu, 21 Sep 2017 16:22:35 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Thu, 21 Sep 2017 13:22:34 -0300 Message-Id: <20170921162234.847-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 21 Sep 2017 16:22:40 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] qemu.py: Call logging.basicConfig() automatically X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , ldoktor@redhat.com, Fam Zheng , stefanha@gmail.com, Amador Pahim , armbru@redhat.com, mreitz@redhat.com, Cleber Rosa Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 Fixes: 4738b0a85a0c2031fddc71b51cccebce0c4ba6b1 Signed-off-by: Eduardo Habkost Reviewed-by: Cleber Rosa Acked-by: Lukáš Doktor --- scripts/qemu.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/qemu.py b/scripts/qemu.py index 5e02dd8e78..73d6031e02 100644 --- a/scripts/qemu.py +++ b/scripts/qemu.py @@ -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