Skip to content

Commit

Permalink
Use rfc3339 timestamps in telegraf log output
Browse files Browse the repository at this point in the history
closes #1564
  • Loading branch information
sparrc committed Oct 11, 2016
1 parent 1ff721a commit 3f4b710
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"io"
"log"
"os"
"time"

"github.com/influxdata/wlog"
)
Expand All @@ -19,8 +20,9 @@ type telegrafLog struct {
writer io.Writer
}

func (t *telegrafLog) Write(p []byte) (n int, err error) {
return t.writer.Write(p)
func (t *telegrafLog) Write(b []byte) (n int, err error) {
return t.writer.Write(
append([]byte(time.Now().UTC().Format(time.RFC3339)+" "), b...))
}

// SetupLogging configures the logging output.
Expand All @@ -30,6 +32,7 @@ func (t *telegrafLog) Write(p []byte) (n int, err error) {
// interpreted as stdout. If there is an error opening the file the
// logger will fallback to stdout.
func SetupLogging(debug, quiet bool, logfile string) {
log.SetFlags(0)
if debug {
wlog.SetLevel(wlog.DEBUG)
}
Expand Down

0 comments on commit 3f4b710

Please sign in to comment.