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.
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.