log

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DebugEnvVar       = "LOGGER_DEBUG"
	LogSourceEnvVar   = "LOGGER_LOG_SOURCE"
	LogSkipHdrsEnvVar = "LOGGER_SKIP_HEADERS"
)
View Source
const (
	LevelDebug = slog.LevelDebug
	LevelInfo  = slog.LevelInfo
	LevelWarn  = slog.LevelWarn
	LevelError = slog.LevelError
	LevelFatal = slog.LevelError + 4
	LevelPanic = slog.LevelError + 8
)

Variables

This section is empty.

Functions

func ClearDebugToggleSignal

func ClearDebugToggleSignal()

func ConfigFromEnv added in v0.13.0

func ConfigFromEnv() *cfgapi.Config

func Configure added in v0.3.0

func Configure(config *cfgapi.Config) error

func Debugging added in v0.13.0

func Debugging(source string) bool

func EnableDebug

func EnableDebug(source string) bool

func Flush

func Flush()

func GetOtelHandler added in v0.13.0

func GetOtelHandler() (slog.Handler, uint32)

func SetOtelHandler added in v0.13.0

func SetOtelHandler(h slog.Handler) slog.Handler

func SetOutput added in v0.13.0

func SetOutput(w io.Writer) io.Writer

func SetStdLogger

func SetStdLogger(source string)

func SetupDebugToggleSignal

func SetupDebugToggleSignal(sig os.Signal)

Types

type Attr added in v0.13.0

type Attr = slog.Attr

type Handler added in v0.13.0

type Handler struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewHandler added in v0.13.0

func NewHandler(source string) *Handler

func (*Handler) Enabled added in v0.13.0

func (h *Handler) Enabled(_ context.Context, lvl Level) bool

func (*Handler) FormatAttrs added in v0.13.0

func (h *Handler) FormatAttrs(buf *bytes.Buffer, r *slog.Record)

func (*Handler) FormatMessage added in v0.13.0

func (h *Handler) FormatMessage(buf *bytes.Buffer, r *slog.Record)

func (*Handler) Handle added in v0.13.0

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

func (*Handler) LegacyFormatMessage added in v0.13.0

func (h *Handler) LegacyFormatMessage(buf *bytes.Buffer, r *slog.Record)

func (*Handler) WithAttrs added in v0.13.0

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

func (*Handler) WithGroup added in v0.13.0

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

func (*Handler) WriteAttr added in v0.13.0

func (h *Handler) WriteAttr(buf *bytes.Buffer, prefix string, a Attr)

type Level

type Level = slog.Level

type Logger

type Logger interface {
	Log(lvl Level, msg string, attrs ...Attr)
	Debug(msg string, attrs ...Attr)
	Info(msg string, attrs ...Attr)
	Warn(msg string, attrs ...Attr)
	Error(msg string, attrs ...Attr)
	Fatal(msg string, attrs ...Attr)
	Panic(msg string, attrs ...Attr)

	Debugf(format string, args ...any)
	Infof(format string, args ...any)
	Warnf(format string, args ...any)
	Errorf(format string, args ...any)
	Fatalf(format string, args ...any)
	Panicf(format string, args ...any)

	LogBlock(lvl Level, prefix, format string, args ...any)
	DebugBlock(prefix string, format string, args ...any)
	InfoBlock(prefix string, format string, args ...any)
	WarnBlock(prefix string, format string, args ...any)
	ErrorBlock(prefix string, format string, args ...any)

	WithContext(ctx context.Context) Logger
	WithGroup(name string) Logger
	WithAttrs(args ...any) Logger

	Enabled(ctx context.Context, lvl Level) bool

	DebugEnabled() bool
	EnableDebug(bool) bool

	Flush()
	SlogHandler() slog.Handler
}

func Default

func Default() Logger

func Get

func Get(source string) Logger

func NewLogger

func NewLogger(source string) Logger

type OtelHandler added in v0.13.0

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

func NewOtelHandler added in v0.13.0

func NewOtelHandler(source string) *OtelHandler

func (*OtelHandler) Enabled added in v0.13.0

func (o *OtelHandler) Enabled(ctx context.Context, level slog.Level) (enabled bool)

func (*OtelHandler) GetHandler added in v0.13.0

func (o *OtelHandler) GetHandler() slog.Handler

func (*OtelHandler) Handle added in v0.13.0

func (o *OtelHandler) Handle(ctx context.Context, r slog.Record) error

func (*OtelHandler) NewChildHandlerWithAttrs added in v0.13.0

func (o *OtelHandler) NewChildHandlerWithAttrs(attrs []Attr) *OtelHandler

func (*OtelHandler) NewChildHandlerWithGroup added in v0.13.0

func (o *OtelHandler) NewChildHandlerWithGroup(group string) *OtelHandler

func (*OtelHandler) WithAttrs added in v0.13.0

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

func (*OtelHandler) WithGroup added in v0.13.0

func (o *OtelHandler) WithGroup(name string) slog.Handler

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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