Documentation ¶
Index ¶
Constants ¶
View Source
const ( LevelFieldName = "logger.level" LevelDefault = level.Error )
Variables ¶
View Source
var Component = &app.Component{ Dependencies: app.Components{ configurator.Component, }, Constructor: func(container container.Container) error { return container.Provides( NewConfig, NewReConfigurationWithConfigurator, func(l *ReConfiguration) *logrus.Logger { return l.Logger }, func(l *ReConfiguration) Logger { return l }, func(l *ReConfiguration) Debuger { return l }, func(l *ReConfiguration) Informer { return l }, func(l *ReConfiguration) Warner { return l }, func(l *ReConfiguration) Printer { return l }, ) }, BindFlags: func(flagSet *pflag.FlagSet, container container.Container) error { return container.Invoke(func(config *Config) { flagSet.StringVar(&config.Level, LevelFieldName, LevelDefault, "setting log level") }) }, Serve: func(c container.Container) error { logger, err := container.Get[*ReConfiguration](c) if err != nil { return err } reConfiguration, err := container.Get[configurator.ReConfiguration](c) if err != nil { return err } reConfiguration.Registration(logger) logger.Info("logger: registration in the reConfigurator") closer, err := container.Get[closer.Closer](c) if err != nil { return err } appConfig, err := container.Get[*app.Config](c) if err != nil { return err } logger.Infof("app: '%s', pid '%d' - started", appConfig.Name, appConfig.PID) ctx, cancelFunc := context.WithCancel(closer.GetContext()) defer cancelFunc() <-ctx.Done() logger.Infof("app: '%s', pid '%d' - shutdown", appConfig.Name, appConfig.PID) return nil }, }
Functions ¶
func NewWithConfigurator ¶
func NewWithConfigurator(config *Config, configurator configurator.Configurator) (*logrus.Logger, error)
Types ¶
type Config ¶
type Config struct {
Level string
}
func Configuration ¶
func Configuration(config *Config, configurator configurator.Configurator) *Config
type Debuger ¶
type Debuger interface { Debugf(string, ...interface{}) Debug(...interface{}) }
Debuger : "debug" level recorder interface.
type Informer ¶
type Informer interface { Infof(string, ...interface{}) Info(...interface{}) }
Informer : "info" level recorder interface.
type Logger ¶
type Logger interface { Debuger Informer Warner Printer Errorf(string, ...interface{}) Error(...interface{}) }
Logger : General logger interface for any implementation.
type ReConfiguration ¶
func NewReConfiguration ¶
func NewReConfiguration(config *Config) (*ReConfiguration, error)
func NewReConfigurationWithConfigurator ¶
func NewReConfigurationWithConfigurator(config *Config, configurator configurator.Configurator) (*ReConfiguration, error)
func (*ReConfiguration) ReConfiguration ¶
func (reConfiguration *ReConfiguration) ReConfiguration(configurator configurator.Configurator) error
Click to show internal directories.
Click to hide internal directories.