Documentation ¶
Index ¶
- Constants
- Variables
- func Debugf(format string, args ...interface{})
- func Errorf(format string, args ...interface{})
- func Fatalf(err error, format string, args ...interface{})
- func GenRequestID() string
- func GetRqClientIPFromCtx(ctx context.Context) string
- func GetRqExecTimeFromCtx(ctx context.Context) float64
- func GetRqIDFromCtx(ctx context.Context) string
- func GetRqURIFromCtx(ctx context.Context) string
- func Infof(format string, args ...interface{})
- func Infow(args ...interface{})
- func NewLogger(config Configuration, loggerInstance int) error
- func Panicf(format string, args ...interface{})
- func Report(err error, format string, args ...interface{})
- func SetRqIDToCtx(ctx context.Context) context.Context
- func SetTimeToCtx(ctx context.Context) context.Context
- func Warnf(format string, args ...interface{})
- type Configuration
- type Fields
- type LoggerV2
Constants ¶
const ( //Debug has verbose message Debug = "debug" //Info is default log level Info = "info" //Warn is for logging messages about possible issues Warn = "warn" //Error is for logging errors Error = "error" //Fatal is for logging fatal messages. The sytem shutsdown after logging the message. Fatal = "fatal" )
const ( InstanceZapLogger int = iota InstanceLogrusLogger )
Variables ¶
var ( RqIDCtxKey = contextKey("request_id") RqClientIPCtxKey = contextKey("client_ip") RqExecTimeCtxKey = contextKey("exec_time") RqURICtxKey = contextKey("request_uri") )
Context key definition. RqIDCtxKey is request ID context key. RqClientIPCtxKey is request client IP context key. ExecTimeCtxKey is execute time context key.
Functions ¶
func GenRequestID ¶
func GenRequestID() string
func GetRqClientIPFromCtx ¶
GetRqClientIPFromCtx get client IP in context and returns as string.
func GetRqExecTimeFromCtx ¶
GetRqExecTimeFromCtx get exec time in context and returns as string.
func GetRqIDFromCtx ¶
GetRqIDFromCtx get request ID in context and returns as string.
func GetRqURIFromCtx ¶
GetRqURIFromCtx get exec time in context and returns as string.
func NewLogger ¶
func NewLogger(config Configuration, loggerInstance int) error
NewLogger returns an instance of logger
func SetRqIDToCtx ¶
SetRqIDToCtx set request ID to context
func SetTimeToCtx ¶
SetTimeToCtx get exec time in context and returns as string.
Types ¶
type Configuration ¶
type Configuration struct { EnableConsole bool ConsoleJSONFormat bool ConsoleLevel string EnableFile bool FileJSONFormat bool }
Configuration stores the config for the logger For some loggers there can only be one level across writers, for such the level of Console is picked by default
type Fields ¶
type Fields map[string]interface{}
Fields Type to pass when we want to call WithFields for structured logging
type LoggerV2 ¶
type LoggerV2 interface { Debugf(format string, args ...interface{}) Infof(format string, args ...interface{}) Infow(args ...interface{}) Warnf(format string, args ...interface{}) Errorf(format string, args ...interface{}) Fatalf(err error, format string, args ...interface{}) Panicf(format string, args ...interface{}) Report(err error, format string, args ...interface{}) WithFields(keyValues Fields) LoggerV2 }
LoggerV2 is our contract for the logger