logx

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package logx provides a tiny, thread-safe holder for an injected logger.Logger. It exists so each capability can expose a SetLogger/GetLogger pair that defaults to a no-op without re-implementing the atomic swap logic.

The logger is optional: until one is injected, Slot.Get returns logger.NopLogger, which discards everything. A minimal build that never constructs a logger therefore pays nothing beyond the no-op calls.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Slot

type Slot struct {
	// contains filtered or unexported fields
}

Slot is a lock-free holder for an optional logger. The zero value is ready to use and reports a no-op logger until Slot.Set is called. A Slot must not be copied after first use.

func (*Slot) Get

func (s *Slot) Get() logger.Logger

Get returns the active logger, or logger.NopLogger if none has been set. Get never returns nil and is safe for concurrent use.

func (*Slot) Set

func (s *Slot) Set(l logger.Logger)

Set installs l as the active logger. Passing nil resets the slot to the no-op logger. Set is safe for concurrent use.

Jump to

Keyboard shortcuts

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