From 4441c2eb1ba29cfa43be1787c96adebfeb762b39 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Fri, 16 May 2014 18:10:04 -0700 Subject: [PATCH] add -max param to gotail utility --- cmd/gotail/gotail.go | 3 +++ tail.go | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/gotail/gotail.go b/cmd/gotail/gotail.go index 4b5b5d3..12c61d3 100644 --- a/cmd/gotail/gotail.go +++ b/cmd/gotail/gotail.go @@ -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 } diff --git a/tail.go b/tail.go index 87debed..e4b770b 100644 --- a/tail.go +++ b/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