Documentation
¶
Overview ¶
Package config provides utilities for configuring logr from JSON configuration files.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfigureTargets ¶
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"
}
ConsoleOptions specifies options for console-based log targets.
type Factories ¶
type Factories struct {
TargetFactory TargetFactory // can be nil
FormatterFactory FormatterFactory // can be nil
}
Factories provides custom factories for creating targets and formatters that are not built-in to logr.
type FormatterFactory ¶
FormatterFactory creates a log formatter from a format string and options.
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"`
}
TargetCfg defines the configuration for a single log target, including its type, format, and output levels.
type TargetFactory ¶
TargetFactory creates a log target from a type string and options.