logging

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromContext

func FromContext(ctx context.Context) *slog.Logger

FromContext returns the a logger instance, either a newly initialised logger if one doesn't exist, a fieldless logger if the provided context is nil, or a logger retrieved from the provided context.

The ability to call FromContext with a nil context and get a clean logger instance eliminates the need for a logging.New() constructor.

func New

func New() *slog.Logger

func ToContext

func ToContext(ctx context.Context, args ...any) (*slog.Logger, context.Context)

ToContext adds the provided fields to the logger returned by WithContext, then stores it in the provided context against the loggerKey key.

Types

This section is empty.

Jump to

Keyboard shortcuts

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