Skip to content

Latest commit

 

History

History
40 lines (28 loc) · 919 Bytes

README.md

File metadata and controls

40 lines (28 loc) · 919 Bytes

logrus-nats

Build Status

A Logrus hook for sending data to NATS

Installation

go get github.com/trillium-labs/logrus-nats

Usage

package main

import (
	"github.com/Sirupsen/logrus"
	"github.com/trillium-labs/logrus-nats"
	"os"
)

func main() {
	logrus.SetFormatter(&logrus.JSONFormatter{})

	logrus.SetOutput(os.Stderr)

	servers := []string{"nats://localhost:4222"}
	hook := logrusnats.NewNATSHook(servers, "my-subject")
	logrus.AddHook(hook)

	logrus.Warn("warning")
	logrus.Info("info")
	logrus.Debug("debug")
}

Credits

Based on AMQP handler by vladoatanasov.

License

Released under the MIT License.