rcrowley / go-metrics

Go port of Coda Hale's Metrics library
Other
3.43k stars 493 forks source link

Use interface for logger instead of log.Logger struct #155

Closed hasnickl closed 7 years ago

hasnickl commented 8 years ago

It is useful to enable periodic metrics logging using metrics.Log() function, however it is hard coded to use the golang logger:

func Log(r Registry, freq time.Duration, l *log.Logger) {
    LogScaled(r, freq, time.Nanosecond, l)
}

This function should use an interface to support metrics logging with any library:

type Logger interface {
    Printf(format string, v ...interface{})
}

func Log(r Registry, freq time.Duration, l Logger) {
    LogScaled(r, freq, time.Nanosecond, l)
}

This allows metrics logging to utilize any logging library that provides Printf()

galexrt commented 8 years ago

+1

mihasya commented 7 years ago

TY for the fix