config

package
v2.0.21 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2023 License: MIT Imports: 10 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigureTargets

func ConfigureTargets(lgr *logr.Logr, config map[string]TargetCfg, factories *Factories) error

ConfigureTargets replaces the current list of log targets with a new one based on a map of name->TargetCfg. The map of TargetCfg's would typically be serialized from a JSON source or can be programmatically created.

An optional set of factories can be provided which will be called to create any target types or formatters not built-in.

To append log targets to an existing config, use `(*Logr).AddTarget` or `(*Logr).AddTargetFromConfig` instead.

Types

type ConsoleOptions

type ConsoleOptions struct {
	Out string `json:"out"` // one of "stdout", "stderr"
}

type Factories

type Factories struct {
	TargetFactory    TargetFactory    // can be nil
	FormatterFactory FormatterFactory // can be nil
}

type FormatterFactory

type FormatterFactory func(format string, options json.RawMessage) (logr.Formatter, error)

type TargetCfg

type TargetCfg struct {
	Type          string          `json:"type"` // one of "console", "file", "tcp", "syslog", "none".
	Options       json.RawMessage `json:"options,omitempty"`
	Format        string          `json:"format"` // one of "json", "plain", "gelf"
	FormatOptions json.RawMessage `json:"format_options,omitempty"`
	Levels        []logr.Level    `json:"levels"`
	MaxQueueSize  int             `json:"maxqueuesize,omitempty"`
}

type TargetFactory

type TargetFactory func(targetType string, options json.RawMessage) (logr.Target, error)

Jump to

Keyboard shortcuts

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