Merge branch 'knaggita-issue#53'

This commit is contained in:
Florian Bruhin 2016-08-05 15:13:59 +02:00
commit 30c7e4a152
6 changed files with 38 additions and 0 deletions

View File

@ -26,6 +26,8 @@ Added
`unix-filename-rubout`.
- New `fonts -> completion.category` setting to customize the font used for
completion category headers.
- New `:debug-log-capacity` command to adjust how many lines are logged into RAM
(to report bugs which are difficult to reproduce).
Changed
~~~~~~~

View File

@ -220,6 +220,7 @@ Contributors, sorted by the number of commits in descending order:
* zwarag
* xd1le
* oniondreams
* knaggita
* issue
* haxwithaxe
* evan

View File

@ -1400,6 +1400,7 @@ These commands are mainly intended for debugging. They are hidden if qutebrowser
|<<debug-console,debug-console>>|Show the debugging console.
|<<debug-crash,debug-crash>>|Crash for debugging purposes.
|<<debug-dump-page,debug-dump-page>>|Dump the current page's content to a file.
|<<debug-log-capacity,debug-log-capacity>>|Change the number of log lines to be stored in RAM.
|<<debug-pyeval,debug-pyeval>>|Evaluate a python string and display the results as a web page.
|<<debug-set-fake-clipboard,debug-set-fake-clipboard>>|Put data into the fake clipboard and enable logging, used for tests.
|<<debug-trace,debug-trace>>|Trace executed code via hunter.
@ -1442,6 +1443,15 @@ Dump the current page's content to a file.
==== optional arguments
* +*-p*+, +*--plain*+: Write plain text instead of HTML.
[[debug-log-capacity]]
=== debug-log-capacity
Syntax: +:debug-log-capacity 'capacity'+
Change the number of log lines to be stored in RAM.
==== positional arguments
* +'capacity'+: Number of lines for the log.
[[debug-pyeval]]
=== debug-pyeval
Syntax: +:debug-pyeval [*--quiet*] 's'+

View File

@ -234,3 +234,16 @@ def repeat_command(win_id, count=None):
cmd = runners.last_command[mode_manager.mode]
commandrunner = runners.CommandRunner(win_id)
commandrunner.run(cmd[0], count if count is not None else cmd[1])
@cmdutils.register(debug=True, name='debug-log-capacity')
def log_capacity(capacity: int):
"""Change the number of log lines to be stored in RAM.
Args:
capacity: Number of lines for the log.
"""
if capacity < 0:
raise cmdexc.CommandError("Can't set a negative log capacity!")
else:
log.ram_handler.change_log_capacity(capacity)

View File

@ -511,6 +511,9 @@ class RAMHandler(logging.Handler):
lines.append(fmt(record))
return '\n'.join(lines)
def change_log_capacity(self, capacity):
self._data = collections.deque(self._data, maxlen=capacity)
class ColoredFormatter(logging.Formatter):

View File

@ -442,6 +442,15 @@ Feature: Various utility commands.
Then qute://log?level=error should be loaded
And the page should contain the plaintext "No messages to show."
Scenario: Using :debug-log-capacity
When I run :debug-log-capacity 100
And I run :message-info oldstuff
And I run :repeat 10 :message-info otherstuff
And I run :message-info newstuff
And I open qute:log
Then the page should contain the plaintext "newstuff"
And the page should not contain the plaintext "oldstuff"
## https://github.com/The-Compiler/qutebrowser/issues/1523
Scenario: Completing a single option argument