https://github.com/zoxpx/tailer
Simple GO program that simulates `tail -F file`.
https://github.com/zoxpx/tailer
Last synced: 26 days ago
JSON representation
Simple GO program that simulates `tail -F file`.
- Host: GitHub
- URL: https://github.com/zoxpx/tailer
- Owner: zoxpx
- License: mit
- Created: 2020-04-17T07:47:18.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-04-17T07:59:22.000Z (about 6 years ago)
- Last Synced: 2023-08-21T21:28:48.481Z (almost 3 years ago)
- Language: Go
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# File Tailer
Simple GO program that simulates `tail -F file`.
Can be controlled via Start/Stop:
```go
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:
```go
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:
```go
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)
}
```