github.com/keltia/go-ipfs@v0.3.8-0.20150909044612-210793031c63/thirdparty/eventlog/entry.go (about) 1 package eventlog 2 3 import ( 4 "time" 5 6 "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/Sirupsen/logrus" 7 "github.com/ipfs/go-ipfs/util" 8 ) 9 10 type entry struct { 11 loggables []Loggable 12 system string 13 event string 14 } 15 16 // Log logs the event unconditionally (regardless of log level) 17 // TODO add support for leveled-logs once we decide which levels we want 18 // for our structured logs 19 func (e *entry) Log() { 20 e.log() 21 } 22 23 // log is a private method invoked by the public Log, Info, Error methods 24 func (e *entry) log() { 25 // accumulate metadata 26 accum := Metadata{} 27 for _, loggable := range e.loggables { 28 accum = DeepMerge(accum, loggable.Loggable()) 29 } 30 31 // apply final attributes to reserved keys 32 // TODO accum["level"] = level 33 accum["event"] = e.event 34 accum["system"] = e.system 35 accum["time"] = util.FormatRFC3339(time.Now()) 36 37 // TODO roll our own event logger 38 logrus.WithFields(map[string]interface{}(accum)).Info(e.event) 39 }