logrus_sns

package module
v0.0.0-...-244468e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 18, 2017 License: MIT Imports: 6 Imported by: 0

README

SNS Hook for Logrus

Install

$ go get github.com/stvvan/logrus_sns

Usage
package main

import (
	"github.com/Sirupsen/logrus"
	"github.com/stvvan/logrus_sns"
)

func main() {
	snsHook, err := logrus_sns.NewSNSHook("topic_arn", "subject", "us-east-1")

	if err != nil {
		panic(err)
	}

	log.AddHook(snsHook)

	log.WithFields(log.Fields{
		"error": "errorMsg",
	}).Error("error!")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SNSHook

type SNSHook struct {
	// Messages with a log level not contained in this array
	// will not be dispatched. If nil, all messages will be dispatched.
	AcceptedLevels []logrus.Level
	Session        *sns.SNS
	TopicArn       *string
	Subject        *string
	Extra          map[string]interface{}
}

SNSHook is a logrus Hook for dispatching messages to the specified topics on AWS SNS

func NewSNSHook

func NewSNSHook(topicArn, subject, region string) (*SNSHook, error)

func NewSNSHookWithSession

func NewSNSHookWithSession(topicArn, subject string, s *session.Session) (*SNSHook, error)

func (*SNSHook) Fire

func (hook *SNSHook) Fire(entry *logrus.Entry) error

func (*SNSHook) Levels

func (hook *SNSHook) Levels() []logrus.Level

Levels define the level of logs which will be sent to SNS

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL