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.
Click to show internal directories.
Click to hide internal directories.