slog

package module
v0.0.0-...-b87209e Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2023 License: Apache-2.0 Imports: 11 Imported by: 3

Documentation

Overview

Package slog provides the slog handler.

Index

Constants

View Source
const (
	// DefaultFormat is the default format for slog.
	DefaultFormat = "text"
	// DefaultFile is the default target for slog.
	DefaultFile = "os.Stderr"
)
View Source
const Name = "slog"

Name is this providers name.

Variables

This section is empty.

Functions

func Factory

func Factory(sections []string, configs types.ConfigData, opts ...log.Option) (log.ProviderType, error)

Factory is the factory for a slog provider.

func WithFile

func WithFile(n string) log.Option

WithFile sets the target for the logger, available options: os.Stdout, os.Stderr, /somedir/somefile.

func WithFormat

func WithFormat(n string) log.Option

WithFormat sets the format for the logger.

Types

type Config

type Config struct {
	log.Config

	// Format is the log format, either json or text.
	Format string `json:"format" yaml:"format"`
	File   string `json:"file" yaml:"file"`
}

Config is the config struct for slog.

func NewConfig

func NewConfig(section []string, configs types.ConfigData, opts ...log.Option) (Config, error)

NewConfig creates a new config.

type Provider

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

Provider is the provider for slog.

func (*Provider) Handler

func (p *Provider) Handler() (slog.Handler, error)

Handler returns the configure handler.

func (*Provider) Key

func (p *Provider) Key() string

Key returns an identifier for this handler provider with its config.

func (*Provider) Start

func (p *Provider) Start() error

Start configures the slog Handler.

func (*Provider) Stop

func (p *Provider) Stop(_ context.Context) error

Stop closes if required a open log file.

Jump to

Keyboard shortcuts

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