Categorygithub.com/bearmini/logrus_firehose/v2
modulepackage
2.0.2
Repository: https://github.com/bearmini/logrus_firehose.git
Documentation: pkg.go.dev

# README

logrus_firehose

GoDoc

AWS Firehose Hook for Logrus :walrus:

Usage

import (
    "github.com/aws/aws-sdk-go-v2/aws"
    "github.com/aws/aws-sdk-go-v2/config"
    "github.com/bearmini/logrus_firehose"
    "github.com/sirupsen/logrus"
)

func main() {
    awsConfig := config.LoadDefaultConfig(context.TODO(), config.WithRegion("us-west-2"))
    hook, err := logrus_firehose.NewWithAWSConfig("my_stream", awsConfig)

    // 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.

messageif message is not set, entry.Message is added to log data in "message" field.
stream_namestream_name is the stream name for Firehose. If not set, defaultStreamName is used as stream name.

# Functions

NewWithConfig returns initialized logrus hook for Firehose with persistent Firehose logger.

# Structs

FirehoseHook is logrus hook for AWS Firehose.
No description provided by the author