add -max param to gotail utility
This commit is contained in:
parent
136cda4961
commit
4441c2eb1b
|
@ -12,7 +12,9 @@ import (
|
|||
func args2config() (tail.Config, int64) {
|
||||
config := tail.Config{Follow: true}
|
||||
n := int64(0)
|
||||
maxlinesize := int(0)
|
||||
flag.Int64Var(&n, "n", 0, "tail from the last Nth location")
|
||||
flag.IntVar(&maxlinesize, "max", 0, "max line size")
|
||||
flag.BoolVar(&config.Follow, "f", false, "wait for additional data to be appended to the file")
|
||||
flag.BoolVar(&config.ReOpen, "F", false, "follow, and track file rename/rotation")
|
||||
flag.BoolVar(&config.Poll, "p", false, "use polling, instead of inotify")
|
||||
|
@ -20,6 +22,7 @@ func args2config() (tail.Config, int64) {
|
|||
if config.ReOpen {
|
||||
config.Follow = true
|
||||
}
|
||||
config.MaxLineSize = maxlinesize
|
||||
return config, n
|
||||
}
|
||||
|
||||
|
|
4
tail.go
4
tail.go
|
@ -234,7 +234,7 @@ func (tail *Tail) tailFileSync() {
|
|||
return
|
||||
}
|
||||
}
|
||||
}else if err == io.EOF {
|
||||
} else if err == io.EOF {
|
||||
if !tail.Follow {
|
||||
return
|
||||
}
|
||||
|
@ -248,7 +248,7 @@ func (tail *Tail) tailFileSync() {
|
|||
}
|
||||
return
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
// non-EOF error
|
||||
tail.Killf("Error reading %s: %s", tail.Filename, err)
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue