config

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LevelNameFieldName defines the command-line flag name for setting the log level.
	// Example: --logger.level=debug
	LevelNameFieldName = "logger.level"
)

Variables

View Source
var Component = &component.Component{
	Name: "logger.Logrus.config",
	Init: component.StepFunc(func(container container.Container) error {
		return container.Provide(NewConfig)
	}),
	BindFlags: component.BindFlags(func(flagSet flag.FlagSet, container container.Container) error {
		return container.Invoke(func(config *Config) {
			flagSet.StringVar(&config.levelName, LevelNameFieldName, LevelNameDefault, "level on logger")
		})
	}),
	Configuration: component.StepFunc(func(container container.Container) error {
		return container.Invoke(Configuration)
	}),
}
View Source
var (
	// LevelNameDefault defines the default log level as a string.
	// It corresponds to logger.Error (lowercase "error").
	LevelNameDefault = strings.ToLower(logger.Error.String())
)

Functions

This section is empty.

Types

type Config

type Config struct {

	// Level is the parsed logger.Level enum value, converted from levelName.
	Level logger.Level
	// contains filtered or unexported fields
}

Config holds the logger configuration that can be set via command-line flags or configuration files. It includes the log level as both string and parsed enum.

func Configuration

func Configuration(config *Config, configurator configurator.Configurator) (*Config, error)

Configuration applies configuration values to the Config struct. It reads from the configurator, sets defaults, and validates the log level. Returns an error if the level name cannot be parsed into a valid logger.Level.

The function is designed to be used with container.Invoke in the PreRun phase.

func NewConfig

func NewConfig() *Config

NewConfig creates a new Config instance with default values. The actual configuration will be applied later via Configuration function and command-line flag binding.

Jump to

Keyboard shortcuts

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