logrusutil

package
v0.0.814 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2020 License: Apache-2.0 Imports: 3 Imported by: 1

Documentation

Overview

Package logrusutil implements some helpers for using logrus

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComponentInit

func ComponentInit(component string)

ComponentInit is a syntax sugar for easier Init

func CreateDefaultFormatter

func CreateDefaultFormatter() logrus.Formatter

CreateDefaultFormatter creates a default JSON formatter

func Init

func Init(formatter *DefaultFieldsFormatter)

Init set Logrus formatter if DefaultFieldsFormatter.wrappedFormatter is nil &logrus.JSONFormatter{} will be used instead

Types

type DefaultFieldsFormatter

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

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

func (*DefaultFieldsFormatter) Format

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

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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