[python logging] How to disable handler?

I have a use case in which we occasionally want to disable logging to Sentry via a command-line flag for debugging purposes. When we were using raven this code did the job:

    if self._parsed_args.debug:
        for handler in self.logger.root.handlers:
            if handler.name == "console":
                # Activate console logging handler at the debug level
                # Deactivate other logging handlers by setting their
                # levels very high
                    # Assumes that the console logging level in the
                    # config is set to a value >logging.DEBUG
                    console_level = logging_config["handlers"]["console"]["level"]
                except (KeyError, TypeError):
                    console_level = 100

Since moving to sentry-sdk, this no longer works in that exceptions from the script running in debug mode are logged to Sentry. I guess that means that the integrations.logging.EventHandler instance is not included in the self.logger.root.handlers collection?

What is the correct way to temporarily disable the Sentry handler?

I suppose I could do:

if not self._parsed_args.debug:

but I am hoping for something a bit less like a sledgehammer than that :slight_smile: