CouchDB Hooks for Logrus
With go get
:
$ go get github.com/codehakase/couchdbrus
package main
import (
"github.com/sirupsen/logrus"
"github.com/codehakase/couchdbrus"
"github.com/ryanjyoder/couchdb"
)
// see test for sample implementation of client
var client *couchdb.Client
func main() {
log := logrus.New()
couchdbHook, err := couchdbrus.NewHook(client, "mylogdatabaseName")
if err != nil {
// do proper error handling here...
log.Fatalf("could not create couchdb hook: %v",
err)
}
log.Hooks.Add(couchdbHook)
log.WithFields(logrus.Fields{
"hostname": "hakaselabs",
"source": "spacex",
"tag": "test-tag",
}).Info("Hello Captain we can see the moon!")
}
Francis Sunday - @codehakase