Add :debug-log-capacity command
This commit is contained in:
parent
323b181227
commit
d25e1fde04
@ -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)
|
||||
|
@ -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):
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user