github.com/johnnyeven/libtools@v0.0.0-20191126065708-61829c1adf46/log/context/context.go (about) 1 package context 2 3 import ( 4 "github.com/sirupsen/logrus" 5 ) 6 7 func NewLogIDHook() *LogIDHook { 8 return &LogIDHook{} 9 } 10 11 type LogIDHook struct { 12 } 13 14 func (hook *LogIDHook) Fire(entry *logrus.Entry) error { 15 entry.Data["log_id"] = GetLogID() 16 return nil 17 } 18 19 func (hook *LogIDHook) Levels() []logrus.Level { 20 return logrus.AllLevels 21 }