Documentation
¶
Index ¶
- Constants
- func Debug(ctx context.Context, err error, metadata KV, message string)
- func Debugf(ctx context.Context, err error, metadata KV, formatedMsg string, ...)
- func Error(ctx context.Context, err error, metadata KV, message string)
- func Errorf(ctx context.Context, err error, metadata KV, formatedMsg string, ...)
- func Fatal(ctx context.Context, err error, metadata KV, message string)
- func Fatalf(ctx context.Context, err error, metadata KV, formatedMsg string, ...)
- func GetCtxRequestID(ctx context.Context) string
- func GetCtxSource(ctx context.Context) interface{}
- func GetCtxUserInfo(ctx context.Context) interface{}
- func Info(ctx context.Context, err error, metadata KV, message string)
- func Infof(ctx context.Context, err error, metadata KV, formatedMsg string, ...)
- func SetConfig(config *Config) error
- func SetCtxRequestID(ctx context.Context, requestID ...string) context.Context
- func SetCtxSource(ctx context.Context, source interface{}) context.Context
- func SetCtxUserInfo(ctx context.Context, userInfo interface{}) context.Context
- func Warn(ctx context.Context, err error, metadata KV, message string)
- func Warnf(ctx context.Context, err error, metadata KV, formatedMsg string, ...)
- type Config
- type Engine
- type KV
- type Level
- type Logger
Constants ¶
View Source
const ( KeyCtxRequestID = "request_id" KeyCtxUserInfo = "user_info" KeyCtxSource = "source" )
View Source
const ( DebugLevel = logger.DebugLevel InfoLevel = logger.InfoLevel WarnLevel = logger.WarnLevel ErrorLevel = logger.ErrorLevel FatalLevel = logger.FatalLevel )
Level options
Variables ¶
This section is empty.
Functions ¶
func GetCtxRequestID ¶
GetCtxRequestID returns request_id from context
func GetCtxSource ¶
func GetCtxUserInfo ¶
func SetCtxRequestID ¶
SetCtxRequestID generates & sets request_id to context
func SetCtxUserInfo ¶
Types ¶
type Config ¶
type Config struct { // AppName is your application name // it will be printed as `app` in log AppName string // Environment is your application environment running on // it will be printed as `env` in log // `dev` | `development` | `local` will mark your app under development env Environment string // Level is minimum log level to be printed (default: DEBUG) Level Level // TimeFormat is for log time format (default: RFC3339) TimeFormat string // WithCaller toggle to print which line is calling the log (default: false) WithCaller bool // CallerSkip is offset number for which caller line you wants to be print (default: 0) CallerSkip int // WithStack is a toggle to print which stack trace error located (default: false) WithStack bool // StackLevel is minimum log level for zap stack trace (default: ERROR) StackLevel *Level // StackMarshaller, function to get and log the stack trace for zerolog (default: `zerolog/pkgerrors`) StackMarshaller func(err error) interface{} // UseJSON is a toggle to format log as json (default: false) UseJSON bool // UseColor is a toggle to colorize your log console // note: it only works using `zerolog` engine and under `development` environment UseColor bool // UseMultiWriters is a toggle to print log into log file and log console // note: FilePath must be filled UseMultiWriters bool // FilePath a file path to write the log as a file // note: if you fill the file path, your console log will be empty. FilePath string // Engine is logger to be used Engine Engine }
Config for Log configuration
Click to show internal directories.
Click to hide internal directories.