Major Logging Overhaul

in this commit:

- centralize logging output handler.
- set global Info/Debug/Error log levels based on config file or flags.
- remove per-plugin debug arg handling.
- add a I!, D!, or E! to every log message.
- add configuration option to specify where to send logs.

closes #1786
This commit is contained in:
Cameron Sparr
2016-09-30 22:37:56 +01:00
parent 78ced6bc30
commit c7834209d2
52 changed files with 363 additions and 269 deletions

View File

@@ -81,7 +81,7 @@ func (t *Tail) Start(acc telegraf.Accumulator) error {
for _, filepath := range t.Files {
g, err := globpath.Compile(filepath)
if err != nil {
log.Printf("ERROR Glob %s failed to compile, %s", filepath, err)
log.Printf("E! Error Glob %s failed to compile, %s", filepath, err)
}
for file, _ := range g.Match() {
tailer, err := tail.TailFile(file,
@@ -118,7 +118,7 @@ func (t *Tail) receiver(tailer *tail.Tail) {
var line *tail.Line
for line = range tailer.Lines {
if line.Err != nil {
log.Printf("ERROR tailing file %s, Error: %s\n",
log.Printf("E! Error tailing file %s, Error: %s\n",
tailer.Filename, err)
continue
}
@@ -126,7 +126,7 @@ func (t *Tail) receiver(tailer *tail.Tail) {
if err == nil {
t.acc.AddFields(m.Name(), m.Fields(), m.Tags(), m.Time())
} else {
log.Printf("Malformed log line in %s: [%s], Error: %s\n",
log.Printf("E! Malformed log line in %s: [%s], Error: %s\n",
tailer.Filename, line.Text, err)
}
}
@@ -139,7 +139,7 @@ func (t *Tail) Stop() {
for _, t := range t.tailers {
err := t.Stop()
if err != nil {
log.Printf("ERROR stopping tail on file %s\n", t.Filename)
log.Printf("E! Error stopping tail on file %s\n", t.Filename)
}
t.Cleanup()
}