|
|
@ -7,10 +7,12 @@ import (
|
|
|
|
"log"
|
|
|
|
"log"
|
|
|
|
"strconv"
|
|
|
|
"strconv"
|
|
|
|
"strings"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
func (r *Reporter) runLogProcessor() {
|
|
|
|
func (r *Reporter) runLogProcessor() {
|
|
|
|
tailer, err := tail.TailFile(r.LogFile, tail.Config{
|
|
|
|
var err error
|
|
|
|
|
|
|
|
r.tailer, err = tail.TailFile(r.LogFile, tail.Config{
|
|
|
|
Follow: true,
|
|
|
|
Follow: true,
|
|
|
|
ReOpen: true,
|
|
|
|
ReOpen: true,
|
|
|
|
Poll: true,
|
|
|
|
Poll: true,
|
|
|
@ -19,8 +21,13 @@ func (r *Reporter) runLogProcessor() {
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
log.Fatalf("failed to tail log file: %v", err)
|
|
|
|
log.Fatalf("failed to tail log file: %v", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for line := range tailer.Lines {
|
|
|
|
|
|
|
|
// TODO: For now this only cares about individual streams it ignores the sum lines
|
|
|
|
for {
|
|
|
|
|
|
|
|
select {
|
|
|
|
|
|
|
|
case line := <- r.tailer.Lines:
|
|
|
|
|
|
|
|
if line == nil {
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
}
|
|
|
|
if len(line.Text) > 5 {
|
|
|
|
if len(line.Text) > 5 {
|
|
|
|
id := line.Text[1:4]
|
|
|
|
id := line.Text[1:4]
|
|
|
|
stream, err := strconv.Atoi(strings.TrimSpace(id))
|
|
|
|
stream, err := strconv.Atoi(strings.TrimSpace(id))
|
|
|
@ -65,9 +72,10 @@ func (r *Reporter) runLogProcessor() {
|
|
|
|
r.ReportingChannel <- report
|
|
|
|
r.ReportingChannel <- report
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
case <- time.After(100 * time.Millisecond):
|
|
|
|
if !r.running {
|
|
|
|
if !r.running {
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|