From e7755f5d9f8a5e995b83a239c05016cf1d58abba Mon Sep 17 00:00:00 2001 From: Martin Tournoij Date: Tue, 4 Apr 2017 17:13:08 +0100 Subject: [PATCH] Add :debug-log-filter none This allows us to clear any filters. Useful for users, and needed for the tests. --- CHANGELOG.asciidoc | 2 ++ qutebrowser/misc/utilcmds.py | 14 ++++++++++---- tests/end2end/features/utilcmds.feature | 7 +++++-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 74bf9e661..81ad97343 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -24,6 +24,8 @@ Added - New `ui -> keyhint-delay` setting to configure the delay until the keyhint overlay pops up. - New `-s` option for `:open` to force a HTTPS scheme. +- `:debug-log-filter` now accepts `none` as an argument to clear any log + filters. Changed ~~~~~~~ diff --git a/qutebrowser/misc/utilcmds.py b/qutebrowser/misc/utilcmds.py index 1998e8341..fc777c2e9 100644 --- a/qutebrowser/misc/utilcmds.py +++ b/qutebrowser/misc/utilcmds.py @@ -293,16 +293,22 @@ def debug_log_filter(filters: str): """Change the log filter for console logging. Args: - filters: A comma separated list of logger names. + filters: A comma separated list of logger names. Can also be "none" to + clear any existing filters. """ + if log.console_filter is None: + raise cmdexc.CommandError("No log.console_filter. Not attached " + "to a console?") + + if filters.strip().lower() == 'none': + log.console_filter.names = None + return + if not set(filters.split(',')).issubset(log.LOGGER_NAMES): raise cmdexc.CommandError("filters: Invalid value {} - expected one " "of: {}".format(filters, ', '.join(log.LOGGER_NAMES))) - if log.console_filter is None: - raise cmdexc.CommandError("No log.console_filter. Not attached " - "to a console?") log.console_filter.names = filters.split(',') diff --git a/tests/end2end/features/utilcmds.feature b/tests/end2end/features/utilcmds.feature index aee57e053..5696de75d 100644 --- a/tests/end2end/features/utilcmds.feature +++ b/tests/end2end/features/utilcmds.feature @@ -166,5 +166,8 @@ Feature: Miscellaneous utility commands exposed to the user. Then the error "filters: Invalid value blah - expected one of: statusbar, *" should be shown Scenario: Using debug-log-filter - When I run :debug-log-filter webview - Then no crash should happen + When I run :debug-log-filter commands,ipc,webview + And I run :enter-mode insert + And I run :debug-log-filter none + And I run :leave-mode + Then "Entering mode KeyMode.insert *" should not be logged