logging

package
v0.0.0-...-f98e9bb Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2025 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

wrappers for slog methods see: https://pkg.go.dev/log/slog#example-package-Wrapping

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Audit

func Audit(ctx context.Context, msg string, args ...any)

func BufferDefaultLogs

func BufferDefaultLogs()

func Debug

func Debug(ctx context.Context, msg string, args ...any)

func Error

func Error(ctx context.Context, msg string, args ...any)

func FlushBufferedLogs

func FlushBufferedLogs(ctx context.Context, handle func(context.Context, slog.Record) error) []error

func FlushBufferedLogsToStderr

func FlushBufferedLogsToStderr()

func Info

func Info(ctx context.Context, msg string, args ...any)

func Init

func Init(
	conf *Config,
	contextGetters common.ContextGetters,
) (closer common.Closer, err error)

func Module

func Module(module common.Module)

func NewBufferedLogger

func NewBufferedLogger(level slog.Leveler) slog.Handler

func NewJsonLogger

func NewJsonLogger(o *Options) slog.Handler

func SetGlobalLoggingLevel

func SetGlobalLoggingLevel(level slog.Leveler)

func Trace

func Trace(ctx context.Context, msg string, args ...any)

func Warn

func Warn(ctx context.Context, msg string, args ...any)

Types

type Config

type Config struct {
	Level  Level  `json:"level" env:"UNIOND_LOGGING_LEVEL"`
	Driver Driver `json:"driver" env:"UNIOND_LOGGING_DRIVER" validate:"oneof=stderr stdout file"`
}

func DefaultConfig

func DefaultConfig() Config

type Driver

type Driver string
const (
	Stderr Driver = "stderr"
	Stdout Driver = "stdout"
	File   Driver = "file"
)

type Level

type Level slog.Level
const (
	LevelError Level = Level(slog.LevelError)
	LevelWarn  Level = Level(slog.LevelWarn)
	LevelAudit Level = Level(slog.LevelInfo + 2)
	LevelInfo  Level = Level(slog.LevelInfo)
	LevelDebug Level = Level(slog.LevelDebug)
	LevelTrace Level = Level(slog.LevelDebug - 4)
)

func LevelFromString

func LevelFromString(levelString string) Level

func (Level) Level

func (level Level) Level() slog.Level

Level implements slog.Leveler.

func (Level) MarshalJSON

func (level Level) MarshalJSON() ([]byte, error)

func (Level) String

func (level Level) String() string

func (*Level) UnmarshalJSON

func (level *Level) UnmarshalJSON(data []byte) error

type Options

type Options struct {
	Writer          io.Writer
	Level           slog.Leveler
	IncludeLocation bool
	ContextValues   []common.ContextValue
}

Jump to

Keyboard shortcuts

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