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