-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update and complete documentation * small linter fixes
- Loading branch information
Showing
16 changed files
with
154 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,44 @@ | ||
![ci](https://github.com/nxadm/tail/workflows/ci/badge.svg)[![Go Reference](https://pkg.go.dev/badge/github.com/nxadm/tail.svg)](https://pkg.go.dev/github.com/nxadm/tail) | ||
|
||
This project is an active, drop-in replacement for the | ||
[abandoned](https://en.wikipedia.org/wiki/HPE_Helion) Go tail library at | ||
[hpcloud](https://github.com/hpcloud/tail). This fork adds support for go | ||
modules, updates the dependencies, adds features and fixes bugs. Go 1.9 is the | ||
oldest compiler release supported. | ||
# tail functionality in Go | ||
|
||
# Go package for tail-ing files | ||
nxadm/tail provides a Go library that emulates the features of the BSD `tail` | ||
program. The library comes with full support for truncation/move detection as | ||
it is designed to work with log rotation tools. The library works on all | ||
operating systems supported by Go, including POSIX systems like Linux and | ||
*BSD, and MS Windows. Go 1.9 is the oldest compiler release supported. | ||
|
||
A Go package striving to emulate the features of the BSD `tail` program. | ||
A simple example: | ||
|
||
```Go | ||
t, err := tail.TailFile("/var/log/nginx.log", tail.Config{Follow: true}) | ||
// Create a tail | ||
t, err := tail.TailFile( | ||
"/var/log/nginx.log", tail.Config{Follow: true, ReOpen: true}) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
// Print the text of each received line | ||
for line := range t.Lines { | ||
fmt.Println(line.Text) | ||
} | ||
``` | ||
|
||
See [API documentation](http://godoc.org/github.com/nxadm/tail). | ||
|
||
## Log rotation | ||
|
||
Tail comes with full support for truncation/move detection as it is | ||
designed to work with log rotation tools. | ||
See [API documentation](https://pkg.go.dev/github.com/nxadm/tail). | ||
|
||
## Installing | ||
|
||
go get github.com/nxadm/tail/... | ||
|
||
## History | ||
|
||
This project is an active, drop-in replacement for the | ||
[abandoned](https://en.wikipedia.org/wiki/HPE_Helion) Go tail library at | ||
[hpcloud](https://github.com/hpcloud/tail). Next to | ||
[addressing open issues/PRs of the original project](https://github.com/nxadm/tail/issues/6), | ||
nxadm/tail continues the development by keeping up to date with the Go toolchain | ||
(e.g. go modules) and dependencies, completing the documentation, adding features | ||
and fixing bugs. | ||
|
||
## Examples | ||
Examples, e.g. used to debug an issue, are kept in the [examples directory](/examples). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ package main | |
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/nxadm/tail" | ||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,19 @@ | ||
// Copyright (c) 2019 FOSS contributors of https://github.com/nxadm/tail | ||
// +build windows | ||
|
||
package tail | ||
|
||
import ( | ||
"github.com/nxadm/tail/winfile" | ||
"os" | ||
|
||
"github.com/nxadm/tail/winfile" | ||
) | ||
|
||
// Deprecated: this function is only useful internally and, as such, | ||
// it will be removed from the API in a future major release. | ||
// | ||
// OpenFile proxies a os.Open call for a file so it can be correctly tailed | ||
// on POSIX and non-POSIX OSes like MS Windows. | ||
func OpenFile(name string) (file *os.File, err error) { | ||
return winfile.OpenFile(name, os.O_RDONLY, 0) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.