Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions tail.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@ var (
)

type Line struct {
Text string
Time time.Time
Err error // Error from tail
Text string
Time time.Time
Err error // Error from tail
PartNum int64
Parts int64
}

// NewLine returns a Line with present time.
func NewLine(text string) *Line {
return &Line{text, time.Now(), nil}
return &Line{text, time.Now(), nil, 0, 1}
}

// SeekInfo represents arguments to `os.Seek`
Expand Down Expand Up @@ -223,7 +225,9 @@ func (tail *Tail) tailFileSync() {
tail.Lines <- &Line{
msg,
time.Now(),
fmt.Errorf(msg)}
fmt.Errorf(msg),
0, 1,
}
// Wait a second before seeking till the end of
// file when rate limit is reached.
select {
Expand Down Expand Up @@ -331,8 +335,10 @@ func (tail *Tail) sendLine(line []byte) bool {
string(line), tail.MaxLineSize)
}

for _, line := range lines {
tail.Lines <- &Line{line, now, nil}
parts := int64(len(lines))

for partnum, line := range lines {
tail.Lines <- &Line{line, now, nil, int64(partnum), parts}
rate := tail.rateMon.Tick(nowUnix)
if tail.LimitRate > 0 && rate > tail.LimitRate {
tail.Logger.Printf("Rate limit (%v < %v) reached on file (%v); entering 1s cooloff period.\n",
Expand Down