From: "Lukáš Doktor" <ldoktor@redhat.com>
To: Eduardo Habkost <ehabkost@redhat.com>, qemu-devel@nongnu.org
Cc: "Daniel P. Berrange" <berrange@redhat.com>,
Cleber Rosa <crosa@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 1/3] guestperf: Configure logging on all shell frontends
Date: Sat, 7 Oct 2017 08:53:25 +0200 [thread overview]
Message-ID: <a62690df-1119-3062-1d0a-52aee9f3f8b4@redhat.com> (raw)
In-Reply-To: <20171005172013.3098-2-ehabkost@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 4460 bytes --]
Dne 5.10.2017 v 19:20 Eduardo Habkost napsal(a):
> The logging module will eventually replace the 'debug' parameter
> in QEMUMachine and QEMUMonitorProtocol.
>
> Cc: Daniel P. Berrange <berrange@redhat.com>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> Changes v1 -> v2:
> * Inline init_logging() method on all callers because not all
> classes derive from BaseShell (reported by Lukáš Doktor)
> ---
> tests/migration/guestperf/shell.py | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/tests/migration/guestperf/shell.py b/tests/migration/guestperf/shell.py
> index 7992459a97..b272978f47 100644
> --- a/tests/migration/guestperf/shell.py
> +++ b/tests/migration/guestperf/shell.py
> @@ -26,6 +26,7 @@ sys.path.append(os.path.join(os.path.dirname(__file__),
> import argparse
> import fnmatch
> import platform
> +import logging
>
> from guestperf.hardware import Hardware
> from guestperf.engine import Engine
> @@ -147,6 +148,10 @@ class Shell(BaseShell):
>
> def run(self, argv):
> args = self._parser.parse_args(argv)
> + logging.basicConfig(level=(logging.DEBUG if args.debug else
> + logging.INFO if args.verbose else
> + logging.WARN))
> +
>
> engine = self.get_engine(args)
> hardware = self.get_hardware(args)
> @@ -179,6 +184,10 @@ class BatchShell(BaseShell):
>
> def run(self, argv):
> args = self._parser.parse_args(argv)
> + logging.basicConfig(level=(logging.DEBUG if args.debug else
> + logging.INFO if args.verbose else
> + logging.WARN))
> +
>
> engine = self.get_engine(args)
> hardware = self.get_hardware(args)
> @@ -231,6 +240,10 @@ class PlotShell(object):
>
> def run(self, argv):
> args = self._parser.parse_args(argv)
> + logging.basicConfig(level=(logging.DEBUG if args.debug else
> + logging.INFO if args.verbose else
> + logging.WARN))
> +
>
> if len(args.reports) == 0:
> print >>sys.stderr, "At least one report required"
>
Yep, this does the trick, also using a shared function would be IMO better (especially if we need to tweak the setup), something like
```diff
diff --git a/tests/migration/guestperf/shell.py b/tests/migration/guestperf/shell.py
index b272978..c1108ae 100644
--- a/tests/migration/guestperf/shell.py
+++ b/tests/migration/guestperf/shell.py
@@ -36,6 +36,12 @@ from guestperf.plot import Plot
from guestperf.report import Report
+def _init_logging(args):
+ logging.basicConfig(level=(logging.DEBUG if args.debug else
+ logging.INFO if args.verbose else
+ logging.WARN))
+
+
class BaseShell(object):
def __init__(self):
@@ -148,10 +154,7 @@ class Shell(BaseShell):
def run(self, argv):
args = self._parser.parse_args(argv)
- logging.basicConfig(level=(logging.DEBUG if args.debug else
- logging.INFO if args.verbose else
- logging.WARN))
-
+ _init_logging(args)
engine = self.get_engine(args)
hardware = self.get_hardware(args)
@@ -184,10 +187,7 @@ class BatchShell(BaseShell):
def run(self, argv):
args = self._parser.parse_args(argv)
- logging.basicConfig(level=(logging.DEBUG if args.debug else
- logging.INFO if args.verbose else
- logging.WARN))
-
+ _init_logging(args)
engine = self.get_engine(args)
hardware = self.get_hardware(args)
@@ -240,10 +240,7 @@ class PlotShell(object):
def run(self, argv):
args = self._parser.parse_args(argv)
- logging.basicConfig(level=(logging.DEBUG if args.debug else
- logging.INFO if args.verbose else
- logging.WARN))
-
+ _init_logging(args)
if len(args.reports) == 0:
print >>sys.stderr, "At least one report required"
```
Anyway both versions are fine by me.
Reviewed-by: Lukáš Doktor <ldoktor@redhat.com>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 502 bytes --]
next prev parent reply other threads:[~2017-10-07 6:53 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-05 17:20 [Qemu-devel] [PATCH v2 0/3] scripts: Remove 'debug' parameter from QEMUMachine & QEMUMonitorProtocol Eduardo Habkost
2017-10-05 17:20 ` [Qemu-devel] [PATCH v2 1/3] guestperf: Configure logging on all shell frontends Eduardo Habkost
2017-10-07 6:53 ` Lukáš Doktor [this message]
2017-10-05 17:20 ` [Qemu-devel] [PATCH v2 2/3] scripts: Remove debug parameter from QEMUMonitorProtocol Eduardo Habkost
2017-10-07 8:26 ` Lukáš Doktor
2017-10-10 2:49 ` Eduardo Habkost
2017-10-10 16:03 ` Lukáš Doktor
2017-10-05 17:20 ` [Qemu-devel] [PATCH v2 3/3] scripts: Remove debug parameter from QEMUMachine Eduardo Habkost
2017-10-07 8:34 ` Lukáš Doktor
2017-10-10 2:50 ` Eduardo Habkost
2017-10-10 16:01 ` Lukáš Doktor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a62690df-1119-3062-1d0a-52aee9f3f8b4@redhat.com \
--to=ldoktor@redhat.com \
--cc=berrange@redhat.com \
--cc=crosa@redhat.com \
--cc=ehabkost@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).