AMQP Hook for Logrus
Usage
package main
import (
"github.com/sirupsen/logrus"
"github.com/vladoatanasov/logrus_amqp"
)
func main() {
log := logrus.New()
hook := logrus_amqp.NewAMQPHook("127.0.0.1:5672", "guest", "guest", "exchange-rabbitmq", "routing-key")
// with virtual host
hook := logrus_amqp.NewAMQPHookWithType("127.0.0.1:5672", "guest", "guest", "exchange-rabbitmq", "virtualHost" "routing-key")
log.Hooks.Add(hook)
}
func doWork() {
err := some_useful_func()
if err != nil {
log.WithFields(logrus.Fields{
"topic": "some_useful_func",
}).Error(err)
}
}
With this hook, you can easily send logs to the ELK stack, using rabbitmq as a message broker. You can find a working docker-compose project here