Documentation ¶
Index ¶
- Constants
- Variables
- func AccessLog(ctx context.Context, fields Fields)
- func AppLog(ctx context.Context) *zerolog.Logger
- func Debug(ctx context.Context, msg string, f Fields)
- func Error(ctx context.Context, msg string, f Fields)
- func Fatal(ctx context.Context, msg string, f Fields)
- func Info(ctx context.Context, msg string, f Fields)
- func Init(cc ConfigLog)
- func Panic(ctx context.Context, msg string, f Fields)
- func Stack(ctx context.Context, msg string, f Fields)
- func TraceIdFromCtx(ctx context.Context) (traceId string)
- func Warn(ctx context.Context, msg string, f Fields)
- func WithTraceId(ctx context.Context, traceId string) context.Context
- type ConfigLog
- type Fields
- type LogLevelType
- type Logger
Constants ¶
const ( LogInfo = LogDebug | (1 << iota) LogWarn LogError )
log levels
const (
ContextKeyTraceId ctxKey = iota
)
Variables ¶
var ExpectedPanic = expectedPanic{}
var (
SrvLogger = &srvlogger{}
)
Functions ¶
func TraceIdFromCtx ¶
Types ¶
type ConfigLog ¶
type ConfigLog struct { LogType string `mapstructure:"type"` App struct { FilePath string `mapstructure:"file_path"` Level string `mapstructure:"level"` Enable bool `mapstructure:"enable"` } `mapstructure:"app"` Access struct { FilePath string `mapstructure:"file_path"` Enable bool `mapstructure:"enable"` } `mapstructure:"access"` }
type LogLevelType ¶
type LogLevelType uint
A LogLevelType defines the level logging should be performed at. Used to instruct the SDK which statements should be logged.
const ( // LogOff states that no logging should be performed by the SDK. This is the // default state of the SDK, and should be use to disable all logging. LogOff LogLevelType = iota * 0x1000 // LogDebug state that debug output should be logged by the SDK. This should // be used to inspect request made and responses received. LogDebug )
func LogLevel ¶
func LogLevel(l LogLevelType) *LogLevelType
LogLevel returns the pointer to a LogLevel. Should be used to workaround not being able to take the address of a non-composite literal.
func (*LogLevelType) AtLeast ¶
func (l *LogLevelType) AtLeast(v LogLevelType) bool
AtLeast returns true if this LogLevel is at least high enough to satisfies v. Is safe to use on nil value LogLevelTypes. If LogLevel is nil, will default to LogOff comparison.
func (*LogLevelType) Matches ¶
func (l *LogLevelType) Matches(v LogLevelType) bool
Matches returns true if the v LogLevel is enabled by this LogLevel. Should be used with logging sub levels. Is safe to use on nil value LogLevelTypes. If LogLevel is nil, will default to LogOff comparison.
func (*LogLevelType) Value ¶
func (l *LogLevelType) Value() LogLevelType
Value returns the LogLevel value or the default value LogOff if the LogLevel is nil. Safe to use on nil value LogLevelTypes.
type Logger ¶
type Logger interface { Debug(args ...interface{}) Debugf(format string, args ...interface{}) Info(args ...interface{}) Infof(format string, args ...interface{}) Warn(args ...interface{}) Warnf(format string, args ...interface{}) Error(args ...interface{}) Errorf(format string, args ...interface{}) }
Logger defines shared log interface among qulibs
func NewDummyLogger ¶
func NewDummyLogger() Logger
NewDummyLogger returns a Logger with LogOff level, which means no logs will be wrote.
func NewLogger ¶
func NewLogger(level LogLevelType) Logger
NewLogger returns a Logger with level given.