go get github.com/HeavyHorst/thinkrus
import (
"github.com/HeavyHorst/thinkrus"
"github.com/Sirupsen/logrus"
)
func main() {
log := logrus.New()
hook, err := thinkrus.New("localhost:28015", "test", "logs", thinkrus.WithBatchInterval(5), thinkrus.WithBatchSize(500))
if err == nil {
log.Hooks.Add(hook)
}
defer hook.Close()
}
All log messages are buffered by default to increase the performance. You need to run hook.Close() on program exit to get sure that all messages are written to the database.
The constructor takes three optional configuration options:
- WithBatchInterval(int): flush the buffer at the given interval in seconds. (default is 5s)
- WithBatchSize(int): Max size of the buffer. The buffer gets flushed to the db if this threshold is reached. (default is 200)
- WithSession(s *gorethink.Session): A custom rethinkdb session.
We will insert your message into RethinkDB with the field message.