mirror of
https://github.com/nvbn/thefuck.git
synced 2025-01-18 20:11:17 +00:00
#682: Parse only the last MB of log
This commit is contained in:
parent
bf0867967b
commit
17b7bf8ec2
@ -72,4 +72,6 @@ USER_COMMAND_MARK = u'\u200B' * 10
|
||||
|
||||
LOG_SIZE = 1000
|
||||
|
||||
LOG_SIZE_IN_BYTES = 1024 * 1024
|
||||
|
||||
DIFF_WITH_ALIAS = 0.5
|
||||
|
@ -54,6 +54,12 @@ def _get_output_lines(script, log_file):
|
||||
return screen.display
|
||||
|
||||
|
||||
def _skip_old_lines(log_file):
|
||||
size = os.path.getsize(os.environ['THEFUCK_OUTPUT_LOG'])
|
||||
if size > const.LOG_SIZE_IN_BYTES:
|
||||
log_file.seek(size - const.LOG_SIZE_IN_BYTES)
|
||||
|
||||
|
||||
def get_output(script):
|
||||
"""Reads script output from log.
|
||||
|
||||
@ -76,6 +82,7 @@ def get_output(script):
|
||||
|
||||
try:
|
||||
with open(os.environ['THEFUCK_OUTPUT_LOG'], 'rb') as log_file:
|
||||
_skip_old_lines(log_file)
|
||||
lines = _get_output_lines(script, log_file)
|
||||
output = '\n'.join(lines).strip()
|
||||
debug(u'Received output: {}'.format(output))
|
||||
|
Loading…
x
Reference in New Issue
Block a user