internal

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: MIT Imports: 21 Imported by: 0

Documentation ¶

Index ¶

Constants ¶

View Source
const (
	LevelAll  slog.Level = math.MinInt
	LevelNone slog.Level = math.MaxInt
)

Variables ¶

View Source
var (
	OTEL_LOG_LEVEL = EnvVar[slog.Level]{
		Parent: Const[slog.Level]{slog.LevelInfo},
		Key:    "OTEL_LOG_LEVEL",
	}

	OTEL_SDK_DISABLED = EnvVar[bool]{
		Parent: Const[bool]{false},
		Key:    "OTEL_SDK_DISABLED",
	}
)
View Source
var (
	ErrBadLogLevel = errors.New("bad log level")
)

Functions ¶

func Code ¶ added in v0.0.3

func Code(skip int) (attrs []attribute.KeyValue, function string)

func ParseLogLevel ¶

func ParseLogLevel(_ context.Context, str string) (level slog.Level, err error)

Types ¶

type Config ¶

type Config struct {
	Attributes        []attribute.KeyValue
	Detecors          []resource.Detector
	ErrorHandler      *otel.ErrorHandler
	Getenv            func(string) string
	Host              bool
	LogLevel          *slog.Level
	Logger            *slog.Logger
	Resource          *resource.Resource
	Runtime           bool
	TextMapPropagator propagation.TextMapPropagator
}

func NewConfig ¶

func NewConfig(context.Context) *Config

type Const ¶

type Const[T any] struct {
	Value T
}

func (Const[T]) Get ¶

func (d Const[T]) Get(context.Context, func(string) string) (T, error)

type EnvVar ¶

type EnvVar[T any] struct {
	Parent Variable[T]
	Key    string
}

func (*EnvVar[T]) Get ¶

func (v *EnvVar[T]) Get(
	ctx context.Context,
	getenv func(string) string,
) (t T, err error)

type Handler ¶

type Handler struct {
	Level slog.Level
	Next  slog.Handler
}

func (*Handler) Enabled ¶

func (h *Handler) Enabled(ctx context.Context, level slog.Level) bool

func (*Handler) Handle ¶

func (h *Handler) Handle(ctx context.Context, record slog.Record) error

func (*Handler) WithAttrs ¶

func (h *Handler) WithAttrs(attrs []slog.Attr) slog.Handler

func (*Handler) WithGroup ¶

func (h *Handler) WithGroup(name string) slog.Handler

type NamedShutdowner ¶

type NamedShutdowner struct {
	Shutdowner
	// contains filtered or unexported fields
}

type Option ¶

type Option interface {
	Apply(context.Context, *Config) error
}

type OptionFunc ¶

type OptionFunc func(context.Context, *Config) error

func (OptionFunc) Apply ¶

func (đť‘“ OptionFunc) Apply(ctx context.Context, config *Config) error

type Sauté ¶

type Sauté struct {
	*slog.Logger
	// contains filtered or unexported fields
}

func New ¶

func New(ctx context.Context, config *Config) (s *Sauté, err error)

func (*Sauté) Handle ¶ added in v0.0.2

func (s *Sauté) Handle(err error)

func (*Sauté) SetErrorHandler ¶ added in v0.0.2

func (s *Sauté) SetErrorHandler(config *Config, 𝑓 func(otel.ErrorHandler))

func (*Sauté) Stop ¶

func (s *Sauté) Stop(ctx context.Context)

type Shutdowner ¶

type Shutdowner interface {
	Shutdown(context.Context) error
}

type Variable ¶

type Variable[T any] interface {
	Get(context.Context, func(string) string) (T, error)
}

Jump to

Keyboard shortcuts

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