Skip to content
/ tailer Public

Simple GO program that simulates `tail -F file`.

License

Notifications You must be signed in to change notification settings

zoxpx/tailer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

File Tailer

Simple GO program that simulates tail -F file.

Can be controlled via Start/Stop:

func main() {
	logrus.SetLevel(logrus.TraceLevel)
	ft := tailer.NewFileTailer("/tmp/tmp.xx", os.Stderr, nil).Start()
	go func() {
		time.Sleep(10 * time.Second)
		ft.Stop()
	}()
	time.Sleep(15 * time.Second)
}

Alternatively, control via context/cancellation:

func main() {
	ctx, cancel := context.WithCancel(context.Background())
	go func() {
		time.Sleep(10 * time.Second)
		cancel()
	}()

	logrus.SetLevel(logrus.TraceLevel)
	tailer.NewFileTailer("/tmp/tmp.xx", os.Stderr, ctx).Start()
	time.Sleep(15 * time.Second)
}

Or control via context Timeout:

func main() {
	ctx, _ := context.WithTimeout(context.Background(), 10 * time.Second)

	logrus.SetLevel(logrus.TraceLevel)
	tailer.NewFileTailer("/tmp/tmp.xx", os.Stderr, ctx).Start()
	time.Sleep(15 * time.Second)
}

About

Simple GO program that simulates `tail -F file`.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages