logger

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CtxLoggerKey = &ContextLoggerKey{}
View Source
var ReqIdKey = &RequestIdKey{}

Functions

func AddEntryToContext

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

func AddLoggerToContext

func AddLoggerToContext(log *logrus.Logger, ctx context.Context) context.Context

Adds a logger to a context. Returns the new context with the logger attached.

func GetEntryFromContextOrDefault

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

Gets a logrus entry from the given context. If one

func GetEntryFromEchoContext

func GetEntryFromEchoContext(c echo.Context) *logrus.Entry

Gets a logrus entry from the Echo handler context. If none has been added yet, a new entry is created along with a UUID so that the logging for this unique request can be tracked.

func GetLoggerFromContextOrDefault

func GetLoggerFromContextOrDefault(ctx context.Context) *logrus.Logger

Retrieves the logger from the given context. If there is none, a default logger is returned, so that this function is guaranteed to never return nil.

Types

type ContextLoggerKey

type ContextLoggerKey struct{}

type RequestIdKey

type RequestIdKey struct{}

Jump to

Keyboard shortcuts

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