log

package
v0.74.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package log provides logging abstractions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Enabled

func Enabled(l slog.Level) bool

Enabled returns true for the appropriate level otherwise false.

func ErrorAttr

func ErrorAttr(err error) slog.Attr

func FromContext

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

FromContext returns the logger, if it exists in the context, or nil.

func SetLevel

func SetLevel(lvl string) error

SetLevel sets the logger level.

func Setup

func Setup(cfg *Config) error

Setup sets up the logger with the given configuration.

func WithContext

func WithContext(ctx context.Context, l *slog.Logger) context.Context

WithContext associates a logger to a context.

Types

type Config

type Config struct {
	Attributes []slog.Attr
	IsJSON     bool
	Level      string
}

Config represents the configuration for setting up the logger.

Jump to

Keyboard shortcuts

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