logger

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 26, 2022 License: BSD-3-Clause Imports: 7 Imported by: 0

README

modulus-logger-zap

This is the module for the Modulus framework. It implements Logger interface and uses awesome logging library https://github.com/uber-go/zap.

Documentation

Index

Constants

View Source
const (
	DebugLevel   = "debug"
	InfoLevel    = "info"
	WarningLevel = "warn"
	ErrorLevel   = "error"
	FatalLevel   = "fatal"
)
View Source
const (
	ConsoleType = "console"
	JsonType    = "json"
)

Variables

This section is empty.

Functions

func GetAtomicLevel

func GetAtomicLevel(level string) zap.AtomicLevel

func NewApplicationLogger

func NewApplicationLogger(zapLogger *zap.Logger) application.Logger

func NewZapLogger

func NewZapLogger(cfg *ModuleConfig) *zap.Logger

Types

type Config

type Config struct {
	// Level is the minimum enabled logging level. Note that this is a dynamic
	Level zap.AtomicLevel `json:"level" yaml:"level"`

	// Sampling sets a sampling policy. A nil SamplingConfig disables sampling.
	Sampling *zap.SamplingConfig `json:"sampling" yaml:"sampling"`

	// EncoderConfig sets options for the chosen encoder.
	EncoderConfig encoder.Config `json:"encoderConfig" yaml:"encoderConfig"`

	// OutputPaths is a list of URLs or file paths to write logging output to.
	OutputPaths []string `json:"outputPaths" yaml:"outputPaths"`

	// ErrorOutputPaths is a list of URLs to write internal logger errors to.
	ErrorOutputPaths []string `json:"errorOutputPaths" yaml:"errorOutputPaths"`

	// InitialFields is a collection of fields to add to the root logger.
	InitialFields []zapcore.Field `json:"initialFields" yaml:"initialFields"`

	EncoderConstructor func(interface{}) (zapcore.Encoder, error)
}

func (Config) Build

func (cfg Config) Build(opts ...zap.Option) (*zap.Logger, error)

Build constructs a logger from the Config and Options.

type ConfigBuilder

type ConfigBuilder interface {
	Build(opts ...zap.Option) (*zap.Logger, error)
}

type ModuleConfig

type ModuleConfig struct {
	// contains filtered or unexported fields
}

func NewModuleConfig

func NewModuleConfig(encoderConfig *encoder.Config) *ModuleConfig

NewModuleConfig set nil to encoderConfig to use default encoding settings

func (*ModuleConfig) EncoderConfig

func (l *ModuleConfig) EncoderConfig() encoder.Config

func (*ModuleConfig) InitConfig

func (s *ModuleConfig) InitConfig(config application.Config) error

func (*ModuleConfig) IsDebug

func (l *ModuleConfig) IsDebug() bool

func (*ModuleConfig) ProvidedServices

func (s *ModuleConfig) ProvidedServices() []interface{}

func (*ModuleConfig) SetAppNam

func (l *ModuleConfig) SetAppNam(appName string) error

func (*ModuleConfig) SetLevel

func (l *ModuleConfig) SetLevel(level string) error

func (*ModuleConfig) SetLoggerType

func (l *ModuleConfig) SetLoggerType(loggerType string) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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