mirror of
https://github.com/containers/podman.git
synced 2025-10-17 19:24:04 +08:00
fix(deps): update module github.com/nxadm/tail to v1.4.11
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This commit is contained in:
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