remove sleep from tests (#2555)
This commit is contained in:
committed by
Daniel Nelson
parent
616b66f5cb
commit
1402c158b7
@@ -2,7 +2,6 @@ package tail
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"sync"
|
||||
|
||||
"github.com/hpcloud/tail"
|
||||
@@ -86,7 +85,7 @@ func (t *Tail) Start(acc telegraf.Accumulator) error {
|
||||
for _, filepath := range t.Files {
|
||||
g, err := globpath.Compile(filepath)
|
||||
if err != nil {
|
||||
log.Printf("E! Error Glob %s failed to compile, %s", filepath, err)
|
||||
t.acc.AddError(fmt.Errorf("E! Error Glob %s failed to compile, %s", filepath, err))
|
||||
}
|
||||
for file, _ := range g.Match() {
|
||||
tailer, err := tail.TailFile(file,
|
||||
@@ -124,21 +123,21 @@ func (t *Tail) receiver(tailer *tail.Tail) {
|
||||
var line *tail.Line
|
||||
for line = range tailer.Lines {
|
||||
if line.Err != nil {
|
||||
log.Printf("E! Error tailing file %s, Error: %s\n",
|
||||
tailer.Filename, err)
|
||||
t.acc.AddError(fmt.Errorf("E! Error tailing file %s, Error: %s\n",
|
||||
tailer.Filename, err))
|
||||
continue
|
||||
}
|
||||
m, err = t.parser.ParseLine(line.Text)
|
||||
if err == nil {
|
||||
t.acc.AddFields(m.Name(), m.Fields(), m.Tags(), m.Time())
|
||||
} else {
|
||||
log.Printf("E! Malformed log line in %s: [%s], Error: %s\n",
|
||||
tailer.Filename, line.Text, err)
|
||||
t.acc.AddError(fmt.Errorf("E! Malformed log line in %s: [%s], Error: %s\n",
|
||||
tailer.Filename, line.Text, err))
|
||||
}
|
||||
}
|
||||
if err := tailer.Err(); err != nil {
|
||||
log.Printf("E! Error tailing file %s, Error: %s\n",
|
||||
tailer.Filename, err)
|
||||
t.acc.AddError(fmt.Errorf("E! Error tailing file %s, Error: %s\n",
|
||||
tailer.Filename, err))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,12 +145,12 @@ func (t *Tail) Stop() {
|
||||
t.Lock()
|
||||
defer t.Unlock()
|
||||
|
||||
for _, t := range t.tailers {
|
||||
err := t.Stop()
|
||||
for _, tailer := range t.tailers {
|
||||
err := tailer.Stop()
|
||||
if err != nil {
|
||||
log.Printf("E! Error stopping tail on file %s\n", t.Filename)
|
||||
t.acc.AddError(fmt.Errorf("E! Error stopping tail on file %s\n", tailer.Filename))
|
||||
}
|
||||
t.Cleanup()
|
||||
tailer.Cleanup()
|
||||
}
|
||||
t.wg.Wait()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user