Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accurate 'offset' #165

Open
hi-sb opened this issue Dec 29, 2019 · 0 comments
Open

Accurate 'offset' #165

hi-sb opened this issue Dec 29, 2019 · 0 comments

Comments

@hi-sb
Copy link

hi-sb commented Dec 29, 2019

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
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant