Skip to content

surendarchandra/logrus_firehose

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

logrus_firehose

GoDoc

AWS Firehose Hook for Logrus :walrus:

Usage

import (
    "github.com/Sirupsen/logrus"
    "github.com/beaubrewer/logrus_firehose"
)

func main() {
    hook, err := logrus_firehose.New("my_stream", Config{
        AccessKey: "ABC", // AWS accessKeyId
        SecretKey: "XYZ", // AWS secretAccessKey
        Region:    "us-west-2",
    })

    // set custom fire level
    hook.SetLevels([]logrus.Level{
        logrus.PanicLevel,
        logrus.ErrorLevel,
    })

    // ignore field
    hook.AddIgnore("context")

    // add custome filter
    hook.AddFilter("error", logrus_firehose.FilterError)


    // send log with logrus
    logger := logrus.New()
    logger.Hooks.Add(hook)
    logger.WithFields(f).Error("my_message") // send log data to firehose as JSON
}

Special fields

Some logrus fields have a special meaning in this hook.

message if message is not set, entry.Message is added to log data in "message" field.
stream_name stream_name isthe stream name for Firehose. If not set, defaultStreamName is used as stream name.
logrus_firehose
====

GoDoc

AWS Firehose Hook for Logrus :walrus:

Usage

import (
    "github.com/Sirupsen/logrus"
    "github.com/beaubrewer/logrus_firehose"
)

func main() {
    hook, err := logrus_firehose.New("my_stream", Config{
        AccessKey: "ABC", // AWS accessKeyId
        SecretKey: "XYZ", // AWS secretAccessKey
        Region:    "us-west-2",
    })

    // set custom fire level
    hook.SetLevels([]logrus.Level{
        logrus.PanicLevel,
        logrus.ErrorLevel,
    })

    // ignore field
    hook.AddIgnore("context")

    // add custome filter
    hook.AddFilter("error", logrus_firehose.FilterError)


    // send log with logrus
    logger := logrus.New()
    logger.Hooks.Add(hook)
    logger.WithFields(f).Error("my_message") // send log data to firehose as JSON
}

Special fields

Some logrus fields have a special meaning in this hook.

message if message is not set, entry.Message is added to log data in "message" field.
stream_name stream_name isthe stream name for Firehose. If not set, defaultStreamName is used as stream name.

About

Logrus hook for AWS Firehose

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%