Skip to content

vladoatanasov/logrus_amqp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AMQP Hook for Logrus :walrus:

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages