Documentation ¶
Index ¶
- Constants
- func GetLogger(ctx context.Context) *zap.SugaredLogger
- func GetLoggerWithNoContext() *zap.SugaredLogger
- func GetNewContextWithLogger() (context.Context, *zap.SugaredLogger)
- func LogNewError(log *zap.SugaredLogger, msg string) error
- func LogNewErrorCode(log *zap.SugaredLogger, c codes.Code, msg string) error
- func LogNewErrorCodef(log *zap.SugaredLogger, c codes.Code, format string, a ...interface{}) error
- func LogNewErrorf(log *zap.SugaredLogger, format string, a ...interface{}) error
- func NewContextWithLogger(ctx context.Context) context.Context
- func SetLoggerLevel(logLevel LogLevel)
- type LogLevel
Constants ¶
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 ¶
LogNewErrorCode logs an error msg, and returns error with code and msg.
func LogNewErrorCodef ¶
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 ¶
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