logrusutil

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2018 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package logrusutil implements some helpers for using logrus

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultFieldsFormatter

type DefaultFieldsFormatter struct {
	WrappedFormatter logrus.Formatter
	DefaultFields    logrus.Fields
}

DefaultFieldsFormatter wraps another logrus.Formatter, injecting DefaultFields into each Format() call, existing fields are preserved if they have the same key

func NewDefaultFieldsFormatter

func NewDefaultFieldsFormatter(
	wrappedFormatter logrus.Formatter, defaultFields logrus.Fields,
) *DefaultFieldsFormatter

NewDefaultFieldsFormatter returns a DefaultFieldsFormatter, if wrappedFormatter is nil &logrus.JSONFormatter{} will be used instead

func (*DefaultFieldsFormatter) Format

func (d *DefaultFieldsFormatter) Format(entry *logrus.Entry) ([]byte, error)

Format implements logrus.Formatter's Format. We allocate a a new Fields map in order to not modify the caller's Entry, as that is not a thread safe operation.

Jump to

Keyboard shortcuts

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