Help us shape the future of Go! Take the 2026 Go Developer Survey

logging

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FormatText = "text"
	FormatJSON = "json"
)
View Source
const ComponentKey = "component"

ComponentKey tags every record with the part of the system that wrote it.

Variables

This section is empty.

Functions

func Component

func Component(i do.Injector, component string) (*slog.Logger, error)

Component returns the logger tagged with the component writing through it. component also names the module in the error an absent logger produces.

func Module

func Module(opts ...Option) app.Module

Module provides a *slog.Logger and, unless WithoutDefault says otherwise, makes it the process default.

Types

type Config

type Config struct {
	Level  slog.Level `config:"level"`
	Format string     `config:"format" validate:"required,oneof=text json"`
}

type Option

type Option func(*options)

func WithWriter

func WithWriter(w io.Writer) Option

WithWriter sends records somewhere other than os.Stdout.

func WithoutDefault

func WithoutDefault() Option

WithoutDefault leaves the package-level slog default alone, so a process can boot a logger without every other one in it changing underneath.

Jump to

Keyboard shortcuts

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