log

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2019 License: Apache-2.0, BSD-3-Clause, MIT Imports: 9 Imported by: 0

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