Add :debug-log-filter none

This allows us to clear any filters. Useful for users, and needed for
the tests.
This commit is contained in:
Martin Tournoij 2017-04-04 17:13:08 +01:00
parent 200e439a30
commit e7755f5d9f
No known key found for this signature in database
GPG Key ID: A6258419189EE585
3 changed files with 17 additions and 6 deletions

View File

@ -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
~~~~~~~

View File

@ -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(',')

View File

@ -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