[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v6 6/9] iotests: use python logging for iotests.log()
From: |
John Snow |
Subject: |
Re: [PATCH v6 6/9] iotests: use python logging for iotests.log() |
Date: |
Tue, 3 Mar 2020 15:00:44 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 |
On 2/27/20 9:21 AM, Max Reitz wrote:
> On 27.02.20 01:06, John Snow wrote:
>> We can turn logging on/off globally instead of per-function.
>>
>> Remove use_log from run_job, and use python logging to turn on
>> diffable output when we run through a script entry point.
>>
>> iotest 245 changes output order due to buffering reasons.
>>
>> Signed-off-by: John Snow <address@hidden>
>> ---
>> tests/qemu-iotests/030 | 4 +--
>> tests/qemu-iotests/245 | 1 +
>> tests/qemu-iotests/245.out | 24 ++++++++---------
>> tests/qemu-iotests/iotests.py | 50 +++++++++++++++++++++--------------
>> 4 files changed, 45 insertions(+), 34 deletions(-)
>
> [...]
>
>> diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
>> index b02d7932fa..60c4c7f736 100644
>> --- a/tests/qemu-iotests/iotests.py
>> +++ b/tests/qemu-iotests/iotests.py
>> @@ -35,6 +35,14 @@
>>
>> assert sys.version_info >= (3, 6)
>>
>> +# Use this logger for logging messages directly from the iotests module
>> +logger = logging.getLogger('qemu.iotests')
>> +logger.addHandler(logging.NullHandler())
>
> Hm, I never see another handler added to this, so how can these messages
> actually be printed? Will enabling debug mode somehow make all loggers
> print everything?
>
Implicit fallback to root logger which handles them when the root logger
is configured, which happens when logging.basicConfig is called.
>> +# Use this logger for messages that ought to be used for diff output.
>> +test_logger = logging.getLogger('qemu.iotests.diff_io')
>
> Also, why does logger get a null handler and this by default does not?
> I’m asking because test_logger makes it look like you don’t necessarily
> need a handler for output to be silently discarded.
>
> Max
>
It's a library trick. By adding a null handler at `qemu.iotests` I add a
default handler to everything produced by iotests. When logging is not
configured, this stops messages from being printed -- there IS a default
"nonconfigured" logging behavior and this stops it.
What I learned since the last time I wrote this patchset is that you
only need a NullHandler at some particular root, so "qemu.iotests"
suffices. "qemu.iotests.diff_io" is a child of that other logger.
>> # This will not work if arguments contain spaces but is necessary if we
>> # want to support the override options that ./check supports.
>> qemu_img_args = [os.environ.get('QEMU_IMG_PROG', 'qemu-img')]
>
--
—js
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [PATCH v6 6/9] iotests: use python logging for iotests.log(),
John Snow <=