mirror of
https://github.com/containers/podman.git
synced 2025-11-30 18:18:18 +08:00
Merge pull request #20321 from containers/renovate/github.com-nxadm-tail-1.x
fix(deps): update module github.com/nxadm/tail to v1.4.11
This commit is contained in:
8
vendor/github.com/nxadm/tail/.cirrus.yml
generated
vendored
Normal file
8
vendor/github.com/nxadm/tail/.cirrus.yml
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
task:
|
||||
name: FreeBSD
|
||||
freebsd_instance:
|
||||
image_family: freebsd-12-2
|
||||
install_script: pkg install -y go
|
||||
script: |
|
||||
go build
|
||||
go test -v -race -timeout 2m ./...
|
||||
3
vendor/github.com/nxadm/tail/.gitignore
generated
vendored
3
vendor/github.com/nxadm/tail/.gitignore
generated
vendored
@@ -1,3 +1,2 @@
|
||||
.idea/
|
||||
.test/
|
||||
examples/_*
|
||||
examples/_*
|
||||
|
||||
10
vendor/github.com/nxadm/tail/CHANGES.md
generated
vendored
10
vendor/github.com/nxadm/tail/CHANGES.md
generated
vendored
@@ -1,7 +1,15 @@
|
||||
# Version v1.4.11
|
||||
* Bump fsnotify to v1.6.0. Should fix some issues.
|
||||
|
||||
# Version v1.4.9
|
||||
* Bump fsnotify to v1.5.1 fixes issue #28, hpcloud/tail#90.
|
||||
* PR #27: "Add timeout to tests"by @kokes++. Also timeout on FreeBSD.
|
||||
* PR #29: "Use temp directory for tests, instead of relative" by @ches++.
|
||||
|
||||
# Version v1.4.7-v1.4.8
|
||||
* Documentation updates.
|
||||
* Small linter cleanups.
|
||||
* Added example in test.
|
||||
* Added example in test.
|
||||
|
||||
# Version v1.4.6
|
||||
|
||||
|
||||
5
vendor/github.com/nxadm/tail/CONTRIBUTING.md
generated
vendored
Normal file
5
vendor/github.com/nxadm/tail/CONTRIBUTING.md
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
# Contributing
|
||||
Comments (at Discussions), Issues and PRs are always welcome. In the case of issues,
|
||||
code examples make it easier to reproduce the problem. In the case of PRs add tests
|
||||
if applicable so we make sure nothing breaks for people using the library on different
|
||||
OSes.
|
||||
13
vendor/github.com/nxadm/tail/README.md
generated
vendored
13
vendor/github.com/nxadm/tail/README.md
generated
vendored
@@ -1,12 +1,13 @@
|
||||
[](https://pkg.go.dev/github.com/nxadm/tail)
|
||||
|
||||
[](https://pkg.go.dev/github.com/nxadm/tail#section-documentation)
|
||||

|
||||
[](https://cirrus-ci.com/github/nxadm/tail)
|
||||
# tail functionality in Go
|
||||
|
||||
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.
|
||||
operating systems supported by Go, including POSIX systems like Linux, *BSD,
|
||||
MacOS, and MS Windows. Go 1.12 is the oldest compiler release supported.
|
||||
|
||||
A simple example:
|
||||
|
||||
@@ -24,7 +25,7 @@ for line := range t.Lines {
|
||||
}
|
||||
```
|
||||
|
||||
See [API documentation](https://pkg.go.dev/github.com/nxadm/tail).
|
||||
See [API documentation](https://pkg.go.dev/github.com/nxadm/tail#section-documentation).
|
||||
|
||||
## Installing
|
||||
|
||||
@@ -41,4 +42,4 @@ nxadm/tail continues the development by keeping up to date with the Go toolchain
|
||||
and fixing bugs.
|
||||
|
||||
## Examples
|
||||
Examples, e.g. used to debug an issue, are kept in the [examples directory](/examples).
|
||||
Examples, e.g. used to debug an issue, are kept in the [examples directory](/examples).
|
||||
|
||||
36
vendor/github.com/nxadm/tail/tail.go
generated
vendored
36
vendor/github.com/nxadm/tail/tail.go
generated
vendored
@@ -77,8 +77,9 @@ type Config struct {
|
||||
Pipe bool // The file is a named pipe (mkfifo)
|
||||
|
||||
// Generic IO
|
||||
Follow bool // Continue looking for new lines (tail -f)
|
||||
MaxLineSize int // If non-zero, split longer lines into multiple lines
|
||||
Follow bool // Continue looking for new lines (tail -f)
|
||||
MaxLineSize int // If non-zero, split longer lines into multiple lines
|
||||
CompleteLines bool // Only return complete lines (that end with "\n" or EOF when Follow is false)
|
||||
|
||||
// Optionally, use a ratelimiter (e.g. created by the ratelimiter/NewLeakyBucket function)
|
||||
RateLimiter *ratelimiter.LeakyBucket
|
||||
@@ -97,6 +98,8 @@ type Tail struct {
|
||||
reader *bufio.Reader
|
||||
lineNum int
|
||||
|
||||
lineBuf *strings.Builder
|
||||
|
||||
watcher watch.FileWatcher
|
||||
changes *watch.FileChanges
|
||||
|
||||
@@ -128,6 +131,10 @@ func TailFile(filename string, config Config) (*Tail, error) {
|
||||
Config: config,
|
||||
}
|
||||
|
||||
if config.CompleteLines {
|
||||
t.lineBuf = new(strings.Builder)
|
||||
}
|
||||
|
||||
// when Logger was not specified in config, use default logger
|
||||
if t.Logger == nil {
|
||||
t.Logger = DefaultLogger
|
||||
@@ -202,6 +209,9 @@ func (tail *Tail) closeFile() {
|
||||
}
|
||||
|
||||
func (tail *Tail) reopen() error {
|
||||
if tail.lineBuf != nil {
|
||||
tail.lineBuf.Reset()
|
||||
}
|
||||
tail.closeFile()
|
||||
tail.lineNum = 0
|
||||
for {
|
||||
@@ -229,16 +239,32 @@ func (tail *Tail) readLine() (string, error) {
|
||||
tail.lk.Lock()
|
||||
line, err := tail.reader.ReadString('\n')
|
||||
tail.lk.Unlock()
|
||||
if err != nil {
|
||||
|
||||
newlineEnding := strings.HasSuffix(line, "\n")
|
||||
line = strings.TrimRight(line, "\n")
|
||||
|
||||
// if we don't have to handle incomplete lines, we can return the line as-is
|
||||
if !tail.Config.CompleteLines {
|
||||
// Note ReadString "returns the data read before the error" in
|
||||
// case of an error, including EOF, so we return it as is. The
|
||||
// caller is expected to process it if err is EOF.
|
||||
return line, err
|
||||
}
|
||||
|
||||
line = strings.TrimRight(line, "\n")
|
||||
if _, err := tail.lineBuf.WriteString(line); err != nil {
|
||||
return line, err
|
||||
}
|
||||
|
||||
return line, err
|
||||
if newlineEnding {
|
||||
line = tail.lineBuf.String()
|
||||
tail.lineBuf.Reset()
|
||||
return line, nil
|
||||
} else {
|
||||
if tail.Config.Follow {
|
||||
line = ""
|
||||
}
|
||||
return line, io.EOF
|
||||
}
|
||||
}
|
||||
|
||||
func (tail *Tail) tailFileSync() {
|
||||
|
||||
Reference in New Issue
Block a user