A Go package striving to emulate the features of the BSD tail
program.
fork from github.com/hpcloud/tail
- support go module and remove vendor dir
- upgrade dependent lib to latest version and go version up to go 1.17
- fix goroutine crash possibility
- remove inotify(v1.1.2)
- add fileReaderWrapper to process file stream, use FileReaderWrapperOption(v1.1.2)
require (
github.com/hpcloud/tail v1.0.0
)
require (
github.com/fsnotify/fsnotify v1.6.0 // indirect
golang.org/x/sys v0.11.0 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
)
replace github.com/hpcloud/tail v1.0.0 => github.com/liumingmin/tail v1.0.2
require (
github.com/hpcloud/tail v1.0.0
)
require gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
replace github.com/hpcloud/tail v1.0.0 => github.com/liumingmin/tail v1.1.2
t, err := tail.TailFile("/var/log/nginx.log", tail.Config{Follow: true, Poll: true})
for line := range t.Lines {
fmt.Println(line.Text)
}
See API documentation.
Tail comes with full support for truncation/move detection as it is designed to work with log rotation tools.
go get github.com/hpcloud/tail/...
windows should use poll mode instead of fsnotify
tail.TailFile("/var/log/nginx.log", tail.Config{Follow: true, Poll: true})
This package needs assistance for full Windows support.