logger

package
v0.0.0-...-427675c Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = zap.Config{
	Encoding:         "console",
	Level:            zap.NewAtomicLevelAt(zapcore.DebugLevel),
	OutputPaths:      []string{"stderr"},
	ErrorOutputPaths: []string{"stderr"},
	EncoderConfig: zapcore.EncoderConfig{
		MessageKey:   "message",
		LevelKey:     "level",
		EncodeLevel:  zapcore.CapitalLevelEncoder,
		TimeKey:      "time",
		EncodeTime:   zapcore.ISO8601TimeEncoder,
		CallerKey:    "caller",
		EncodeCaller: zapcore.ShortCallerEncoder,
	},
}

Functions

func Cleanup

func Cleanup()

Cleanup flushes all log entries. The reason is certain loggers might not write each log message to its destination immediately upon receiving it. The logger could accumulate several log messages in memory and then write them out in a single batch. So call Cleanup before the application exits to make sure all buffered logs are properly written. E.g. defer log.Cleanup()

func Debug

func Debug(msg string, fields ...zapcore.Field)

Debug logs a message at level Debug on the standard logger. log.Debug("This is a DEBUG message")

func Error

func Error(msg string, fields ...zapcore.Field)

Error logs a message at level Error on the standard logger. log.Error("This is an ERROR message")

func Fatal

func Fatal(msg string, fields ...zapcore.Field)

Fatal logs a message at level Fatal on the standard logger. After logging, it will call os.Exit(1). log.Fatal("This is a FATAL message")

func Info

func Info(msg string, fields ...zapcore.Field)

Info logs a message at level Info on the standard logger. log.Info("This is an INFO message") log.Info("This is an INFO message with fields", zap.String("region", "APAC"), zap.Int("id", 1))

func InitializeLogger

func InitializeLogger(cfg zap.Config)

func Warn

func Warn(msg string, fields ...zapcore.Field)

Warn logs a message at level Warn on the standard logger. log.Warn("This is a Warn message")

Types

This section is empty.

Jump to

Keyboard shortcuts

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