hpcloud/tail

Accurate 'offset'

hi-sb opened this issue · 0 comments

hi-sb commented

When the 'tail.Tell()' method runs, the next line may have been read. This results in 'offset' not being a precise value. Whether to consider adding a configuration. When the configuration is "true", send "offset" in 'lines' channel

// Config is used to specify how a file must be tailed.
type Config struct {
	// File-specifc
	Location    *SeekInfo // Seek to this location before tailing
	ReOpen      bool      // Reopen recreated files (tail -F)
	MustExist   bool      // Fail early if the file does not exist
	Poll        bool      // Poll for file changes instead of using inotify
	Pipe        bool      // Is a named pipe (mkfifo)
	RateLimiter *ratelimiter.LeakyBucket

	// Generic IO
	Follow      bool // Continue looking for new lines (tail -f)
	MaxLineSize int  // If non-zero, split longer lines into multiple lines

	// Logger, when nil, is set to tail.DefaultLogger
	// To disable logging: set field to tail.DiscardingLogger
	Logger logger
        // add this config 
       LinesOffset bool // When the configuration is "true", send "offset" in 'lines' channel
}
type Line struct {
	Text string
	Time time.Time
	Err  error // Error from tail
        Offset int64 // this tell file offset
}