logx

package
v1.0.320 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CorrelationHeader     = "cid"             // CorrelationHeader is the name of the nats message header for transporting the correlationID.
	CorrelationContextKey = ContextKey("cid") // CorrelationContextKey is the name of the context key used to store the correlationID.
	EcoSystemLoggingKey   = "eco"             // EcoSystemLoggingKey is the name of the logging key used to store the current ecosystem.
	SubsystemLoggingKey   = "sub"             // SubsystemLoggingKey is the name of the logging key used to store the current subsystem.
	CorrelationLoggingKey = "cid"             // CorrelationLoggingKey is the name of the logging key used to store the correlation id.
	AreaLoggingKey        = "loc"             // AreaLoggingKey is the name of the logging key used to store the functional area.
)

Variables

This section is empty.

Functions

func ContextWith

func ContextWith(ctx context.Context, area string) (context.Context, *slog.Logger)

ContextWith obtains a new logger with an area parameter. Typically it should be used when obtaining a logger within a programmatic boundary.

func Err

func Err(ctx context.Context, message string, err error, atts ...any) error

Err will output error message to the log and return the error with additional attributes.

func LoggingEntrypoint

func LoggingEntrypoint(ctx context.Context, subsystem string, correlationId string) (context.Context, *slog.Logger)

LoggingEntrypoint returns a new logger and a context containing the logger for use during entry points. An entry point is any code location where correlation has been obtained.

func SetDefault

func SetDefault(level slog.Level, addSource bool, ecosystem string)

SetDefault sets the default logger for an application. This should be done in tha application's main.go before and call to slog to prevent race conditions.

Types

type ContextKey

type ContextKey string

ContextKey is a custom type to avoid context collision.

Jump to

Keyboard shortcuts

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