log

package
v0.0.0-...-2215086 Latest Latest
Warning

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

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

Documentation

Overview

Package log configures a new logger for an application.

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 NewErrorStandardLogger

func NewErrorStandardLogger(logger logur.Logger) *log.Logger

NewErrorStandardLogger returns a new standard logger logging on error level.

func NewLogger

func NewLogger(config Config) logur.Logger

NewLogger creates a new logger.

func SetStandardLogger

func SetStandardLogger(logger logur.Logger)

SetStandardLogger sets the global logger's output to a custom logger instance.

func ToMap

func ToMap(keyvals []interface{}) map[string]interface{}

ToMap creates a map of key-value pairs.

The implementation bellow is from go-kit's JSON 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