log

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultConfig is the default configuration used for the zap-based Logger
	DefaultConfig = &zap.Config{
		Level:             zap.NewAtomicLevelAt(zap.InfoLevel),
		Development:       false,
		DisableCaller:     false,
		DisableStacktrace: false,
		Sampling:          nil,
		Encoding:          "console",
		EncoderConfig: zapcore.EncoderConfig{
			MessageKey:  "msg",
			LevelKey:    "lvl",
			EncodeLevel: zapcore.CapitalColorLevelEncoder,
		},
		OutputPaths:      []string{"stdout"},
		ErrorOutputPaths: nil,
		InitialFields: map[string]interface{}{
			"date": time.Now().Format(time.RFC3339),
		},
	}
)

Functions

func Config

func Config(opts ...zap.Option) *zap.Config

Config builds a new zap.Config with optional Options for configuration

Types

type Logger

type Logger struct {

	// Logger embeds a pointer zap.SugaredLogger to assume its' API
	*zap.SugaredLogger
	// contains filtered or unexported fields
}

Logger is a type alias to Uber's zap logger, saving us from importing zap everywhere and assuming the SugaredLogger's API results low effort logs later

func New

func New(opts ...Option) *Logger

New returns a newly built Logger including all or no Options for configuration

type Option

type Option func(config *zap.Config)

Option is a utility function which is called during Logger initialization to alter or even override the DefaultConfig

func WithCustomConfig

func WithCustomConfig(cfg zap.Config) Option

WithCustomConfig overrides the entire DefaultConfig configuration, replacing the reference with a new zap.Config object which will be used to configure the Logger

func WithDevelopment

func WithDevelopment() Option

WithDevelopment configures the new Logger for use within development contexts

func WithEncoder

func WithEncoder(encoder zapcore.EncoderConfig) Option

WithEncoder configures a custom Encoder for the new Logger

func WithLevel

func WithLevel(level zapcore.Level) Option

WithLevel configures the Logger with a custom logging level

Jump to

Keyboard shortcuts

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