log

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2019 License: Apache-2.0, BSD-3-Clause, MIT Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// FieldComponentName is the key of the component field in the log message.
	FieldComponentName = "component"
	// FieldCorrelationID is the key of the correlation id field in the log message.
	FieldCorrelationID = "correlation_id"
)

Variables

View Source
var (

	// C is an alias for ForContext
	C = ForContext
	// D is an alias for Default
	D = Default
)
View Source
var CorrelationIDHeaders = []string{"X-Correlation-ID", "X-CorrelationID", "X-ForRequest-ID", "X-Request-ID"}

CorrelationIDHeaders are the headers whose values will be taken as a correlation id for incoming requests

Functions

func AddHook

func AddHook(hook logrus.Hook)

AddHook adds a hook to all loggers

func Configure

func Configure(ctx context.Context, settings *Settings) context.Context

Configure creates a new context with a logger using the provided settings.

func ContextWithLogger

func ContextWithLogger(ctx context.Context, entry *logrus.Entry) context.Context

ContextWithLogger returns a new context with the provided logger.

func CorrelationIDForRequest

func CorrelationIDForRequest(request *http.Request) string

CorrelationIDForRequest returns checks the http headers for any of the supported correlation id headers. The first that matches is taken as the correlation id. If none exists a new one is generated.

func Default

func Default() *logrus.Entry

Default returns the default logger

func ForContext

func ForContext(ctx context.Context) *logrus.Entry

ForContext retrieves the current logger from the context.

func RegisterFormatter

func RegisterFormatter(name string, formatter logrus.Formatter) error

RegisterFormatter registers a new logrus Formatter with the given name. Returns an error if there is a formatter with the same name.

Types

type Settings

type Settings struct {
	Level  string
	Format string
	Output io.Writer `mapstructure:"-"`
}

Settings type to be loaded from the environment

func DefaultSettings

func DefaultSettings() *Settings

DefaultSettings returns default values for Log settings

func (*Settings) Validate

func (s *Settings) Validate() error

Validate validates the logging settings

Jump to

Keyboard shortcuts

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