logger

package
v3.0.2-rc.1 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ProductionLogLevel is the level for the production log.
	ProductionLogLevel LogLevel = "PRODUCTION"
	// DevelopmentLogLevel is the level for development log.
	DevelopmentLogLevel LogLevel = "DEVELOPMENT"
	// EnvLoggerLevel is the environment variable name for log level.
	EnvLoggerLevel = "LOGGER_LEVEL"
	// LogCtxIDKey holds the TraceId for log.
	LogCtxIDKey = "TraceId"
)

Variables

This section is empty.

Functions

func GetLogger

func GetLogger(ctx context.Context) *zap.SugaredLogger

GetLogger returns SugaredLogger associated with given context.

func GetLoggerWithNoContext

func GetLoggerWithNoContext() *zap.SugaredLogger

GetLoggerWithNoContext returns a new logger to the caller. Returned logger is not associated with any context.

func GetNewContextWithLogger

func GetNewContextWithLogger() (context.Context, *zap.SugaredLogger)

GetNewContextWithLogger creates a new context with context UUID and logger set func returns both context and logger to the caller.

func LogNewError

func LogNewError(log *zap.SugaredLogger, msg string) error

LogNewError logs an error msg, and returns error with msg.

func LogNewErrorCode

func LogNewErrorCode(log *zap.SugaredLogger, c codes.Code, msg string) error

LogNewErrorCode logs an error msg, and returns error with code and msg.

func LogNewErrorCodef

func LogNewErrorCodef(log *zap.SugaredLogger, c codes.Code, format string, a ...interface{}) error

LogNewErrorCodef logs a formated msg, and returns error with code and msg.

func LogNewErrorf

func LogNewErrorf(log *zap.SugaredLogger, format string, a ...interface{}) error

LogNewErrorf logs a formated msg, and returns error with msg.

func NewContextWithLogger

func NewContextWithLogger(ctx context.Context) context.Context

NewContextWithLogger returns a new child context with context UUID set using key CtxId.

func SetLoggerLevel

func SetLoggerLevel(logLevel LogLevel)

SetLoggerLevel helps set defaultLogLevel, using which newLogger func helps create either development logger or production logger

Types

type LogLevel

type LogLevel string

LogLevel represents the level for the log.

Jump to

Keyboard shortcuts

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