Skip to content

Commit

Permalink
Merge pull request google#1564 from andyxning/add_error_log_for_open_…
Browse files Browse the repository at this point in the history
…log_file

add error log for open log file
  • Loading branch information
tallclair authored Jan 6, 2017
2 parents ba33b5a + 2c1d001 commit 5e78498
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion utils/tail/tail.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ func (t *Tail) attemptOpen() error {
defer t.readerLock.Unlock()
t.readerErr = nil
attempt := 0
var lastErr error
for interval := defaultRetryInterval; ; interval *= 2 {
attempt++
glog.V(4).Infof("Opening %s (attempt %d)", t.filename, attempt)
Expand All @@ -104,6 +105,9 @@ func (t *Tail) attemptOpen() error {
t.reader = bufio.NewReader(t.file)
return nil
}
lastErr = err
glog.V(4).Infof("open log file %s error: %v", t.filename, err)

if interval >= maxRetryInterval {
break
}
Expand All @@ -114,7 +118,7 @@ func (t *Tail) attemptOpen() error {
return fmt.Errorf("watch was cancelled")
}
}
err := fmt.Errorf("can't open log file %s", t.filename)
err := fmt.Errorf("can't open log file %s: %v", t.filename, lastErr)
t.readerErr = err
return err
}
Expand Down

0 comments on commit 5e78498

Please sign in to comment.