logger

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2024 License: MIT Imports: 10 Imported by: 8

Documentation

Index

Constants

View Source
const (
	LevelFieldName = "logger.level"

	LevelDefault = level.Error
)

Variables

View Source
var Component = &app2.Component{
	Dependencies: app2.Components{
		configurator.Component,
	},
	Constructor: app2.Constructor(func(container container.Container) error {
		return container.Provides(
			NewConfig,
			NewWithConfigurator,
			func(Logger *logrus.Logger) Logger { return Logger },
			func(Logger *logrus.Logger) Debuger { return Logger },
			func(Logger *logrus.Logger) Informer { return Logger },
			func(Logger *logrus.Logger) Warner { return Logger },
			func(Logger *logrus.Logger) Printer { return Logger },
		)
	}),
	BindFlags: app2.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: app2.ServeChan(func(container container.Container, isServeChan chan struct{}) error {
		return container.Invoke(func(logger Logger, closer closer.Closer, appConfig *app2.Config) {
			logger.Infof("app: '%s', pid '%d' - started", appConfig.Name, appConfig.PID)

			ctx, cancelFunc := context.WithCancel(closer.GetContext())
			defer cancelFunc()

			isServeChan <- struct{}{}
			<-ctx.Done()

			logger.Infof("app: '%s', pid '%d' - shutdown", appConfig.Name, appConfig.PID)
		})
	}),
}

Functions

func New

func New(config *Config) (*logrus.Logger, error)

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

func NewConfig

func NewConfig() *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 Printer

type Printer interface {
	Print(...interface{})
}

type Warner

type Warner interface {
	Warnf(string, ...interface{})
	Warn(...interface{})
}

Warner : "warning" level recorder interface.

Directories

Path Synopsis
hook

Jump to

Keyboard shortcuts

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