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

promslog

package
v0.72.1 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: Apache-2.0 Imports: 8 Imported by: 209

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// LevelFlagOptions represents allowed logging levels.
	LevelFlagOptions = []string{"debug", "info", "warn", "error"}
	// FormatFlagOptions represents allowed formats.
	FormatFlagOptions = []string{"logfmt", "json"}
)

Functions

func New

func New(config *Config) *slog.Logger

New returns a new slog.Logger. Each logged line will be annotated with a timestamp. The output always goes to stderr.

func NewNopLogger added in v0.60.0

func NewNopLogger() *slog.Logger

NewNopLogger is a convenience function to return an slog.Logger that discards all log records.

Types

type Config

type Config struct {
	Level  *Level
	Format *Format
	Style  LogStyle
	Writer io.Writer
}

Config is a struct containing configurable settings for the logger.

type Format added in v0.63.0

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

Format controls a logging output format. Not concurrency-safe.

func NewFormat added in v0.63.0

func NewFormat() *Format

NewFormat creates a new Format.

func (*Format) Set added in v0.63.0

func (f *Format) Set(s string) error

Set updates the value of the allowed format.

func (*Format) String added in v0.63.0

func (f *Format) String() string

type Level added in v0.63.0

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

Level controls a logging level, with an info default. It wraps slog.LevelVar with string-based level control. Level is safe to be used concurrently.

func NewLevel added in v0.63.0

func NewLevel() *Level

NewLevel returns a new Level.

func (*Level) Level added in v0.65.0

func (l *Level) Level() slog.Level

Level returns the value of the logging level as an slog.Level.

func (*Level) Set added in v0.63.0

func (l *Level) Set(s string) error

Set updates the logging level with the validation.

func (*Level) String added in v0.63.0

func (l *Level) String() string

String returns the current level.

func (*Level) UnmarshalYAML added in v0.63.0

func (l *Level) UnmarshalYAML(unmarshal func(any) error) error

type LogStyle

type LogStyle string

LogStyle represents the common logging formats in the Prometheus ecosystem.

const (
	SlogStyle  LogStyle = "slog"
	GoKitStyle LogStyle = "go-kit"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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