Documentation ¶
Index ¶
- Constants
- func Debug(args ...interface{})
- func DebugWithFields(msg string, fields KV)
- func Debugf(format string, v ...interface{})
- func Debugln(args ...interface{})
- func Debugw(msg string, keyValues KV)
- func Error(args ...interface{})
- func ErrorWithFields(msg string, fields KV)
- func Errorf(format string, v ...interface{})
- func Errorln(args ...interface{})
- func Errors(err error)
- func Errorw(msg string, keyValues KV)
- func Fatal(args ...interface{})
- func FatalWithFields(msg string, fields KV)
- func Fatalf(format string, v ...interface{})
- func Fatalln(args ...interface{})
- func Fatalw(msg string, keyValues KV)
- func GetCtxID(ctx context.Context) string
- func GetCtxRequestID(ctx context.Context) string
- func Info(args ...interface{})
- func InfoWithFields(msg string, fields KV)
- func Infof(format string, v ...interface{})
- func Infoln(args ...interface{})
- func Infow(msg string, keyValues KV)
- func InitLogContext(ctx context.Context) context.Context
- func Print(v ...interface{})
- func Printf(format string, v ...interface{})
- func Println(v ...interface{})
- func SetConfig(config *Config) error
- func SetCtxID(ctx context.Context, contextID string) context.Context
- func SetCtxRequestID(ctx context.Context, uuid string) context.Context
- func SetLevel(level Level)
- func SetLevelString(level string)
- func SetLogger(level logger.Level, lgr logger.Logger) error
- func SetStdLog(config *Config) error
- func StdDebug(ctx context.Context, metadata interface{}, err error, message string)
- func StdDebugf(ctx context.Context, metadata interface{}, err error, format string, ...)
- func StdError(ctx context.Context, metadata interface{}, err error, message string)
- func StdErrorf(ctx context.Context, metadata interface{}, err error, format string, ...)
- func StdFatal(ctx context.Context, metadata interface{}, err error, message string)
- func StdFatalf(ctx context.Context, metadata interface{}, err error, format string, ...)
- func StdInfo(ctx context.Context, metadata interface{}, err error, message string)
- func StdInfof(ctx context.Context, metadata interface{}, err error, format string, ...)
- func StdTrace(ctx context.Context, metadata interface{}, err error, message string)
- func StdTracef(ctx context.Context, metadata interface{}, err error, format string, ...)
- func StdWarn(ctx context.Context, metadata interface{}, err error, message string)
- func StdWarnf(ctx context.Context, metadata interface{}, err error, format string, ...)
- func Warn(args ...interface{})
- func WarnWithFields(msg string, fields KV)
- func Warnf(format string, v ...interface{})
- func Warnln(args ...interface{})
- func Warnw(msg string, keyValues KV)
- type Config
- type Engine
- type KV
- type Level
- type Logger
Constants ¶
const ( TraceLevel = logger.TraceLevel DebugLevel = logger.DebugLevel InfoLevel = logger.InfoLevel WarnLevel = logger.WarnLevel ErrorLevel = logger.ErrorLevel FatalLevel = logger.FatalLevel )
Level option
const (
RFC3339Milli = "2006-01-02T15:04:05.999Z07:00"
)
RFC3339Milli We agree that we want a millisecond precisstion, sadly in golang it's not there. https://github.com/golang/go/issues/13291
Variables ¶
This section is empty.
Functions ¶
func DebugWithFields ¶
DebugWithFields prints debug level log with additional fields. useful when output is in json format
func Debugf ¶
func Debugf(format string, v ...interface{})
Debugf prints debug level log like log.Printf
func ErrorWithFields ¶
ErrorWithFields prints error level log with additional fields. useful when output is in json format
func Errorf ¶
func Errorf(format string, v ...interface{})
Errorf prints error level log like log.Printf
func FatalWithFields ¶
FatalWithFields prints fatal level log with additional fields. useful when output is in json format
func Fatalf ¶
func Fatalf(format string, v ...interface{})
Fatalf prints fatal level log like log.Printf
func GetCtxRequestID ¶
GetCtxRequestID get request id from context
func InfoWithFields ¶
InfoWithFields prints info level log with additional fields. useful when output is in json format
func Infof ¶
func Infof(format string, v ...interface{})
Infof prints info level log like log.Printf
func InitLogContext ¶
InitLogContext will initialize context with some informations Currently it will inject request id using xid Ideally InitLogContext will be wrap around middleware, either grpc or http For Request ID will currently set it with xid if empty. Can be explored with trace id
func SetCtxRequestID ¶
SetCtxRequestID set context with request id
func SetLevel ¶
func SetLevel(level Level)
SetLevel adjusts log level threshold. Only log with level higher or equal with this level will be printed
func SetLevelString ¶
func SetLevelString(level string)
SetLevelString adjusts log level threshold using string
func SetStdLog ¶
SetStdLog will be the entry point for tdk logging library to make sure all Tokopedia services have the same log structures. The general specification will be JSON, request id, context id, metadata, error and message. For more specifications please go to https://tokopedia.atlassian.net/wiki/spaces/EN/pages/694817819/Logging+Format+Standardization
func StdDebugf ¶
func StdDebugf(ctx context.Context, metadata interface{}, err error, format string, args ...interface{})
StdDebugf print trace level log with standardized parameters with formatter.
func StdErrorf ¶
func StdErrorf(ctx context.Context, metadata interface{}, err error, format string, args ...interface{})
StdErrorf print trace level log with standardized parameters with formatter.
func StdFatalf ¶
func StdFatalf(ctx context.Context, metadata interface{}, err error, format string, args ...interface{})
StdFatalf print trace level log with standardized parameters with formatter.
func StdInfof ¶
func StdInfof(ctx context.Context, metadata interface{}, err error, format string, args ...interface{})
StdInfof print trace level log with standardized parameters with formatter.
func StdTracef ¶
func StdTracef(ctx context.Context, metadata interface{}, err error, format string, args ...interface{})
StdTracef print trace level log with standardized parameters with formatter.
func StdWarnf ¶
func StdWarnf(ctx context.Context, metadata interface{}, err error, format string, args ...interface{})
StdWarnf print trace level log with standardized parameters with formatter.
func WarnWithFields ¶
WarnWithFields prints warn level log with additional fields. useful when output is in json format
Types ¶
type Config ¶
type Config struct { // log level, default: debug Level string // Format of the log's time field // default RFC3339="2006-01-02T15:04:05Z07:00" TimeFormat string // AppName is the application name this log belong to AppName string // Caller, option to print caller line numbers. // make sure you understand the overhead when use this Caller bool // LogFile is output file for log other than debug log // this is not needed by default, // application is expected to run in containerized environment LogFile string // DebugFile is output file for debug log // this is not needed by default, // application is expected to run in containerized environment DebugFile string // Deprecated, this field will have no effect // keeping it for backward compatibility Engine Engine // UseColor, option to colorize log in console. // Deprecated true if and only if TKPENV=development UseColor bool // UseJSON, option to print in json format. UseJSON bool // StdLog, option to use standardized Log StdLog bool // CallerSkip, option to skip caller frame CallerSkip int }
Config of log