Go to file
Benoit Sigoure f69ef84e36 Fix race in the detection of truncation.
Before going into ChangeEvents(), the code was calling stat on the file
to know where it was at, which is incorrect as stat could return the new
file size post truncation.  Instead we now ask the file descriptor about
our current offset, so we can compare our offset to the file size to try
to detect truncation.

Truncation detection remains brittle, but this closes an annoying race
we frequently run into.
2015-10-27 22:42:26 -07:00
cmd/gotail Fix imports 2015-09-30 17:50:49 +03:00
ratelimiter include License file of original code 2014-04-29 19:56:11 -07:00
util replace the alarmist panic with Fatal 2013-10-11 18:19:43 -07:00
watch Fix race in the detection of truncation. 2015-10-27 22:42:26 -07:00
winfile add FILE_SHARE_DELETE flag when opening file 2014-07-28 16:38:02 +03:00
.gitignore remove logyard references and update README 2012-10-17 11:56:54 -07:00
.travis.yml Upgrade to fsnotify.v1 2015-10-27 22:42:25 -07:00
CHANGES.md change log entry for last PR 2015-07-03 14:27:12 -07:00
Dockerfile Fix imports 2015-09-30 17:50:49 +03:00
LICENSE.txt add license and copyright 2013-01-07 12:54:49 -08:00
Makefile Fix imports 2015-09-30 17:50:49 +03:00
README.md Fix imports 2015-09-30 17:50:49 +03:00
deps.json Fix tomb import 2014-06-14 23:39:34 -07:00
tail.go Fix race in the detection of truncation. 2015-10-27 22:42:26 -07:00
tail_posix.go support freebsd, like darwin 2014-10-08 12:37:29 +03:00
tail_test.go Fix imports 2015-09-30 17:50:49 +03:00
tail_windows.go Fix imports 2015-09-30 17:50:49 +03:00

README.md

Build Status

Go package for tail-ing files

A Go package striving to emulate the features of the BSD tail program.

t, err := tail.TailFile("/var/log/nginx.log", tail.Config{Follow: true})
for line := range t.Lines {
    fmt.Println(line.Text)
}

See API documentation.

Log rotation

Tail comes with full support for truncation/move detection as it is designed to work with log rotation tools.

Installing

go get github.com/hpcloud/tail/...

Windows support

This package needs assistance for full Windows support.