Add :debug-log-capacity command

This commit is contained in:
knaggita 2016-08-03 20:18:51 +03:00 committed by Florian Bruhin
parent 323b181227
commit d25e1fde04
2 changed files with 16 additions and 0 deletions

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):