Use this to log into Bolt. This hook is created because i need to practice about go programming language. So it is still in initial development version. It only logs into bolt, with key initiated by default using uuid and the value is the entry itself.
The hook could be configured using options provided:
type HookOptions struct {
IDGenerator UniqueID
Dbpath string
FileMode os.FileMode
BoltOptions *bolt.Options
}
Example:
boltHook := boltlogrus.NewBoltHook(boltlogrus.Dbpath("customlog.db"))
log.AddHook(boltHook)
log.WithFields(log.Fields{
"animal": "Dog",
"number": "1",
}).Info("Kenny")
To see the result of the logging, you could use bolter
If you want to implement your own IDGenerator, you just need to implement the interface specified in uniqueid.go
Register your new IDGenerator by using IDGenerator(youOwn)
inside the function of NewBoltHook. You could take a look in hook_test.go
Sometimes you may need to not display the log message to your default terminal console. This may happen when you use multiple hook. Same thing will be logged twice inside your terminal console. hmm, you don't like, do you. So to prevent this, you could try this :
silentLog := logrus.New()
var b bytes.Buffer
silentLog.SetOutput(&b)
//Same goes here, add your newhook
or just use, ioutil.Discard
This hook uses two dependencies of libary :
You could read more at those sources
Any contributions including Creating Issues & PR are appreciated.