Merge qute://plainlog into qute://log?plain
This commit is contained in:
parent
2b629e0d3d
commit
679eaab28f
|
|
@ -23,6 +23,9 @@ Removed
|
|||
|
||||
- The `:debug-log-level` command was removed as it's replaced by the new
|
||||
`logging.level.console` setting.
|
||||
- The `qute://plainlog` special page got replaced by `qute://log?plain` - the
|
||||
names of those pages is considered an implementation detail, and
|
||||
`:messages --plain` should be used instead.
|
||||
|
||||
Changed
|
||||
~~~~~~~
|
||||
|
|
|
|||
|
|
@ -1398,10 +1398,15 @@ class CommandDispatcher:
|
|||
"""
|
||||
if level.upper() not in log.LOG_LEVELS:
|
||||
raise cmdutils.CommandError("Invalid log level {}!".format(level))
|
||||
|
||||
query = QUrlQuery()
|
||||
query.addQueryItem('level', level)
|
||||
if plain:
|
||||
url = QUrl('qute://plainlog?level={}'.format(level))
|
||||
else:
|
||||
url = QUrl('qute://log?level={}'.format(level))
|
||||
query.addQueryItem('plain', None)
|
||||
|
||||
url = QUrl('qute://log')
|
||||
url.setQuery(query)
|
||||
|
||||
self._open(url, tab, bg, window)
|
||||
|
||||
def _open_editor_cb(self, elem):
|
||||
|
|
|
|||
|
|
@ -307,36 +307,31 @@ def qute_version(_url):
|
|||
return 'text/html', src
|
||||
|
||||
|
||||
def _qute_log(url: QUrl, *, html: bool) -> _HandlerRet:
|
||||
"""Shared code between qute://log and qute://plainlog.
|
||||
@add_handler('log')
|
||||
def qute_log(url: QUrl) -> _HandlerRet:
|
||||
"""Handler for qute://log.
|
||||
|
||||
An optional query parameter specifies the minimum log level to print.
|
||||
For example, qute://log?level=warning prints warnings and errors.
|
||||
Level can be one of: vdebug, debug, info, warning, error, critical.
|
||||
"""
|
||||
query = QUrlQuery(url)
|
||||
plain = (query.hasQueryItem('plain') and
|
||||
query.queryItemValue('plain').lower() != 'false')
|
||||
|
||||
if log.ram_handler is None:
|
||||
content = None if html else "Log output was disabled."
|
||||
content = "Log output was disabled." if plain else None
|
||||
else:
|
||||
level = QUrlQuery(url).queryItemValue('level')
|
||||
level = query.queryItemValue('level')
|
||||
if not level:
|
||||
level = 'vdebug'
|
||||
content = log.ram_handler.dump_log(html=html, level=level)
|
||||
content = log.ram_handler.dump_log(html=not plain, level=level)
|
||||
|
||||
template = 'log.html' if html else 'pre.html'
|
||||
template = 'pre.html' if plain else 'log.html'
|
||||
src = jinja.render(template, title='log', content=content)
|
||||
return 'text/html', src
|
||||
|
||||
|
||||
@add_handler('plainlog')
|
||||
def qute_plainlog(url: QUrl) -> _HandlerRet:
|
||||
return _qute_log(url, html=False)
|
||||
|
||||
|
||||
@add_handler('log')
|
||||
def qute_log(url: QUrl) -> _HandlerRet:
|
||||
return _qute_log(url, html=True)
|
||||
|
||||
|
||||
@add_handler('gpl')
|
||||
def qute_gpl(_url: QUrl) -> _HandlerRet:
|
||||
"""Handler for qute://gpl. Return HTML content as string."""
|
||||
|
|
|
|||
|
|
@ -269,10 +269,6 @@ Feature: Special qute:// pages
|
|||
And I wait for "Changing title for idx * to 'log'" in the log
|
||||
Then no crash should happen
|
||||
|
||||
Scenario: Using qute://plainlog directly
|
||||
When I open qute://plainlog
|
||||
Then no crash should happen
|
||||
|
||||
# :version
|
||||
|
||||
Scenario: Open qute://version
|
||||
|
|
|
|||
Loading…
Reference in New Issue