Just setting level=DEBUG when debug is enabled is not enough: we
need to set up a log handler if we want debug messages generated
using logging.getLogger(...).debug() to be printed.
This was not a problem before because logging.debug() calls
logging.basicConfig() implicitly, but it's safer to not rely on
that.
Cc: "Alex Bennée" <alex.bennee@linaro.org>
Cc: Fam Zheng <famz@redhat.com>
Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
tests/vm/basevm.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py
index 3c863bc237..686d88decf 100755
--- a/tests/vm/basevm.py
+++ b/tests/vm/basevm.py
@@ -227,8 +227,8 @@ def main(vmcls):
if not argv and not args.build_qemu and not args.build_image:
print "Nothing to do?"
return 1
- if args.debug:
- logging.getLogger().setLevel(logging.DEBUG)
+ logging.basicConfig(level=(logging.DEBUG if args.debug
+ else logging.WARN))
vm = vmcls(debug=args.debug, vcpus=args.jobs)
if args.build_image:
if os.path.exists(args.image) and not args.force:
--
2.13.5
On Wed, Sep 27, 2017 at 10:03:37AM -0300, Eduardo Habkost wrote: > Just setting level=DEBUG when debug is enabled is not enough: we > need to set up a log handler if we want debug messages generated > using logging.getLogger(...).debug() to be printed. > > This was not a problem before because logging.debug() calls > logging.basicConfig() implicitly, but it's safer to not rely on > that. > > Cc: "Alex Bennée" <alex.bennee@linaro.org> > Cc: Fam Zheng <famz@redhat.com> > Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org> > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> > --- > tests/vm/basevm.py | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) Reviewed-by: Daniel P. Berrange <berrange@redhat.com> Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
On Wed, 09/27 10:03, Eduardo Habkost wrote: > Just setting level=DEBUG when debug is enabled is not enough: we > need to set up a log handler if we want debug messages generated > using logging.getLogger(...).debug() to be printed. > > This was not a problem before because logging.debug() calls > logging.basicConfig() implicitly, but it's safer to not rely on > that. > > Cc: "Alex Bennée" <alex.bennee@linaro.org> > Cc: Fam Zheng <famz@redhat.com> > Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org> > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> > --- > tests/vm/basevm.py | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py > index 3c863bc237..686d88decf 100755 > --- a/tests/vm/basevm.py > +++ b/tests/vm/basevm.py > @@ -227,8 +227,8 @@ def main(vmcls): > if not argv and not args.build_qemu and not args.build_image: > print "Nothing to do?" > return 1 > - if args.debug: > - logging.getLogger().setLevel(logging.DEBUG) > + logging.basicConfig(level=(logging.DEBUG if args.debug > + else logging.WARN)) I find the " ? : " expression in C more readable than this in Python. :) > vm = vmcls(debug=args.debug, vcpus=args.jobs) > if args.build_image: > if os.path.exists(args.image) and not args.force: > -- > 2.13.5 > Reviewed-by: Fam Zheng <famz@redhat.com>
On Wed, Sep 27, 2017 at 09:35:44PM +0800, Fam Zheng wrote: > On Wed, 09/27 10:03, Eduardo Habkost wrote: > > Just setting level=DEBUG when debug is enabled is not enough: we > > need to set up a log handler if we want debug messages generated > > using logging.getLogger(...).debug() to be printed. > > > > This was not a problem before because logging.debug() calls > > logging.basicConfig() implicitly, but it's safer to not rely on > > that. > > > > Cc: "Alex Bennée" <alex.bennee@linaro.org> > > Cc: Fam Zheng <famz@redhat.com> > > Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org> > > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> > > --- > > tests/vm/basevm.py | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py > > index 3c863bc237..686d88decf 100755 > > --- a/tests/vm/basevm.py > > +++ b/tests/vm/basevm.py > > @@ -227,8 +227,8 @@ def main(vmcls): > > if not argv and not args.build_qemu and not args.build_image: > > print "Nothing to do?" > > return 1 > > - if args.debug: > > - logging.getLogger().setLevel(logging.DEBUG) > > + logging.basicConfig(level=(logging.DEBUG if args.debug > > + else logging.WARN)) > > I find the " ? : " expression in C more readable than this in Python. :) I think everybody except Guido does. :) -- Eduardo
Dne 27.9.2017 v 15:03 Eduardo Habkost napsal(a): > Just setting level=DEBUG when debug is enabled is not enough: we > need to set up a log handler if we want debug messages generated > using logging.getLogger(...).debug() to be printed. > > This was not a problem before because logging.debug() calls > logging.basicConfig() implicitly, but it's safer to not rely on > that. > > Cc: "Alex Bennée" <alex.bennee@linaro.org> > Cc: Fam Zheng <famz@redhat.com> > Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org> > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> > --- > tests/vm/basevm.py | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py > index 3c863bc237..686d88decf 100755 > --- a/tests/vm/basevm.py > +++ b/tests/vm/basevm.py > @@ -227,8 +227,8 @@ def main(vmcls): > if not argv and not args.build_qemu and not args.build_image: > print "Nothing to do?" > return 1 > - if args.debug: > - logging.getLogger().setLevel(logging.DEBUG) > + logging.basicConfig(level=(logging.DEBUG if args.debug > + else logging.WARN)) > vm = vmcls(debug=args.debug, vcpus=args.jobs) > if args.build_image: > if os.path.exists(args.image) and not args.force: > Reviewed-by: Lukáš Doktor <ldoktor@redhat.com>
© 2016 - 2026 Red Hat, Inc.