Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/evalphobia/logrus_fluent

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/evalphobia/logrus_fluent

  • v0.5.4
  • Source
  • Go
  • Socket score

Version published
Created
Source

Fluentd Hook for Logrus :walrus:

GoDoc License: Apache 2.0 Release Travis Status wercker Status Coveralls Coverage Go Report Card Downloads Code Climate BCH compliance

Usage

import (
	"github.com/sirupsen/logrus"
	"github.com/evalphobia/logrus_fluent"
)

func main() {
	hook, err := logrus_fluent.NewWithConfig(logrus_fluent.Config{
		Host: "localhost",
		Port: 24224,
	})
	if err != nil {
		panic(err)
	}

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

	// set static tag
	hook.SetTag("original.tag")

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

	// filter func
	hook.AddFilter("error", logrus_fluent.FilterError)

	logrus.AddHook(hook)
}

func logging(ctx context.Context) {
	logrus.WithFields(logrus.Fields{
		"value":   "some content...",
		"error":   errors.New("unknown error"), // this field will be applied filter function in the hook.
		"context": ctx,                         // this field will be ignored in the hook.
	}).Error("error message")
}

Special fields

Some logrus fields have a special meaning in this hook.

  • tag is used as a fluentd tag. (if tag is omitted, Entry.Message is used as a fluentd tag, unless a static tag is set for the hook with hook.SetTag)

FAQs

Package last updated on 11 Jul 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc