Commit ddb0189b authored by Brian Tiger Chow's avatar Brian Tiger Chow

refactor(eventlog) use polite formatter as a direct dependency

License: MIT
Signed-off-by: default avatarBrian Tiger Chow <brian@perfmode.com>
parent 884d629a
......@@ -17,7 +17,7 @@ func Configure(options ...Option) {
// LdJSONFormatter formats the event log as line-delimited JSON
var LdJSONFormatter = func() {
logrus.SetFormatter(&logrus.PoliteJSONFormatter{})
logrus.SetFormatter(&PoliteJSONFormatter{})
}
var TextFormatter = func() {
......
package eventlog
import (
"encoding/json"
"fmt"
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/maybebtc/logrus"
)
type PoliteJSONFormatter struct{}
func (f *PoliteJSONFormatter) Format(entry *logrus.Entry) ([]byte, error) {
serialized, err := json.Marshal(entry.Data)
if err != nil {
return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err)
}
return append(serialized, '\n'), nil
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment