Friday, 23 August 2019

Ingore specific logging line temporarily

I have a method called import_customers() which loads csv-like data.

This methods logs to log-level INFO.

In one case I want to avoid this logging.

I see several ways:

Variant 1: a new kwarg like do_logging=True which I can switch to false.

Variant 2: Use some magic context which ignores this line.

with IgnoreLoggingContext() as context:
    import_customers()

How could I implement IgnoreLoggingContext()?

If you think V1 is better, then please leave a comment.



from Ingore specific logging line temporarily

No comments:

Post a Comment