mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-22 10:57:42 +08:00
- Modified Godeps/Godeps.json by hand - [TEST] Updated welcome docs hash to sharness - [TEST] Updated contact doc - [TEST] disabled breaking test (t0080-repo refs local)
40 lines
943 B
Go
40 lines
943 B
Go
package eventlog
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/Sirupsen/logrus"
|
|
"github.com/ipfs/go-ipfs/util"
|
|
)
|
|
|
|
type entry struct {
|
|
loggables []Loggable
|
|
system string
|
|
event string
|
|
}
|
|
|
|
// Log logs the event unconditionally (regardless of log level)
|
|
// TODO add support for leveled-logs once we decide which levels we want
|
|
// for our structured logs
|
|
func (e *entry) Log() {
|
|
e.log()
|
|
}
|
|
|
|
// log is a private method invoked by the public Log, Info, Error methods
|
|
func (e *entry) log() {
|
|
// accumulate metadata
|
|
accum := Metadata{}
|
|
for _, loggable := range e.loggables {
|
|
accum = DeepMerge(accum, loggable.Loggable())
|
|
}
|
|
|
|
// apply final attributes to reserved keys
|
|
// TODO accum["level"] = level
|
|
accum["event"] = e.event
|
|
accum["system"] = e.system
|
|
accum["time"] = util.FormatRFC3339(time.Now())
|
|
|
|
// TODO roll our own event logger
|
|
logrus.WithFields(map[string]interface{}(accum)).Info(e.event)
|
|
}
|