You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
720 B

8 years ago
8 years ago
  1. package log
  2. import (
  3. "io"
  4. kitlog "github.com/go-kit/kit/log"
  5. )
  6. // NewTMJSONLogger returns a Logger that encodes keyvals to the Writer as a
  7. // single JSON object. Each log event produces no more than one call to
  8. // w.Write. The passed Writer must be safe for concurrent use by multiple
  9. // goroutines if the returned Logger will be used concurrently.
  10. func NewTMJSONLogger(w io.Writer) Logger {
  11. logger := kitlog.NewJSONLogger(w)
  12. logger = kitlog.With(logger, "ts", kitlog.DefaultTimestampUTC)
  13. return &tmLogger{logger}
  14. }
  15. // NewTMJSONLoggerNoTS is the same as NewTMJSONLogger, but without the
  16. // timestamp.
  17. func NewTMJSONLoggerNoTS(w io.Writer) Logger {
  18. logger := kitlog.NewJSONLogger(w)
  19. return &tmLogger{logger}
  20. }