log

package
v0.0.0-...-5a001f1 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const ContextKey = "correlationid"

ContextKey is the key the retrieved (or generated) correlation ID is stored under in the gin Context.

Variables

This section is empty.

Functions

func Middleware

func Middleware(notlogged ...string) gin.HandlerFunc

Middleware returns a gin compatible handler.

func MiddlewareCorrelationId

func MiddlewareCorrelationId(opts ...MiddlewareOption) gin.HandlerFunc

MiddlewareCorrelationId returns a gin compatible handler.

func NewLogger

func NewLogger(config Config) logur.Logger

NewLogger creates a new logger.

func WithFields

func WithFields(logger logur.Logger, fields map[string]interface{}) logur.Logger

WithFields returns a new contextual logger instance with context added to it.

func WithFieldsForHandlers

func WithFieldsForHandlers(ctx *gin.Context, logger logur.Logger, fields map[string]interface{}) logur.Logger

WithFieldsForHandlers returns a new logger instance with a correlation ID in it.

Types

type Config

type Config struct {
	// Format specifies the output log format.
	// Accepted values are: json, logfmt
	Format string

	// Level is the minimum log level that should appear on the output.
	Level string

	// NoColor makes sure that no log output gets colorized.
	NoColor bool
}

Config holds details necessary for logging.

type Header string

Header configures the header from where the correlation ID will be retrieved.

type MiddlewareOption

type MiddlewareOption interface {
	// contains filtered or unexported methods
}

MiddlewareOption configures the correlation ID middleware.

Jump to

Keyboard shortcuts

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