Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi, here is my implementation of feature request #83
It adds 4 configuration options:
LastLines - outputs the last NUM lines.
It's done by finding the location of required line and changing tail.Config.Location according to found location.
While seeking it stepping back by bytes defined by PageSize (4096 default). It's done to avoid reading the whole file.
FromLine - the same as LastLines, but looking for the line from the start.
PageSize - The optional option. Configures the buffer size for step. Might be reasonable to increase if the file is huge.
SeekOnReOpen - By default if a file was reopened no line seek performed.
If this option configured as True - reopened file will be read with the desired line.
If LastLines and FromLine both configured FromLine will be used and LastLines will be ignored.
If NUM of lines 0 or less nothing will happen.
It works with "follow" and without it as well.
I'll appreciate for any comments and suggestions.