[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v8 11/11] iotests: use python logging for iotests.log()
From: |
Max Reitz |
Subject: |
Re: [PATCH v8 11/11] iotests: use python logging for iotests.log() |
Date: |
Tue, 24 Mar 2020 17:14:21 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 |
On 17.03.20 01:41, 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.
>
>
> An extended note on python logging:
Thanks!
> A NullHandler is added to `qemu.iotests` to stop output from being
> generated if this code is used as a library without configuring logging.
> A NullHandler is only needed at the root, so a duplicate handler is not
> needed for `qemu.iotests.diff_io`.
>
> When logging is not configured, messages at the 'WARNING' levels or
> above are printed with default settings. The NullHandler stops this from
> occurring, which is considered good hygiene for code used as a library.
>
> See https://docs.python.org/3/howto/logging.html#library-config
>
> When logging is actually enabled (always at the behest of an explicit
> call by a client script), a root logger is implicitly created at the
> root, which allows messages to propagate upwards and be handled/emitted
> from the root logger with default settings.
>
> When we want iotest logging, we attach a handler to the
> qemu.iotests.diff_io logger and disable propagation to avoid possible
> double-printing.
>
> For more information on python logging infrastructure, I highly
> recommend downloading the pip package `logging_tree`, which provides
> convenient visualizations of the hierarchical logging configuration
> under different circumstances.
>
> See https://pypi.org/project/logging_tree/ for more information.
>
> Signed-off-by: John Snow <address@hidden>
> ---
> tests/qemu-iotests/030 | 4 +--
> tests/qemu-iotests/155 | 2 +-
> tests/qemu-iotests/245 | 1 +
> tests/qemu-iotests/245.out | 24 ++++++++--------
> tests/qemu-iotests/iotests.py | 53 ++++++++++++++++++++---------------
> 5 files changed, 46 insertions(+), 38 deletions(-)
Reviewed-by: Max Reitz <address@hidden>
signature.asc
Description: OpenPGP digital signature
- Re: [PATCH v8 06/11] iotests: drop Python 3.4 compatibility code, (continued)
- [PATCH v8 09/11] iotest 258: use script_main, John Snow, 2020/03/16
- [PATCH v8 07/11] iotests: limit line length to 79 chars, John Snow, 2020/03/16
- [PATCH v8 10/11] iotests: Mark verify functions as private, John Snow, 2020/03/16
- [PATCH v8 08/11] iotests: add script_initialize, John Snow, 2020/03/16
- [PATCH v8 11/11] iotests: use python logging for iotests.log(), John Snow, 2020/03/16
- Re: [PATCH v8 11/11] iotests: use python logging for iotests.log(),
Max Reitz <=