log

package
v0.0.0-...-1bafb4f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 3, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LogInfo = LogDebug | (1 << iota)
	LogWarn
	LogError
)

log levels

View Source
const (
	ContextKeyTraceId ctxKey = iota
)

Variables

View Source
var ExpectedPanic = expectedPanic{}
View Source
var (
	SrvLogger = &srvlogger{
		appLogger: zerolog.New(os.Stdout).With().Timestamp().Logger(),
	}
)

Functions

func AccessLog

func AccessLog(ctx context.Context, fields Fields)

func AppLog

func AppLog(ctx context.Context) *zerolog.Logger

func Debug

func Debug(ctx context.Context, msg string, f Fields)

func Error

func Error(ctx context.Context, msg string, f Fields)

func Fatal

func Fatal(ctx context.Context, msg string, f Fields)

func Info

func Info(ctx context.Context, msg string, f Fields)

func Init

func Init()

func Panic

func Panic(ctx context.Context, msg string, f Fields)

func Stack

func Stack(ctx context.Context, msg string, f Fields)

func TraceIdFromCtx

func TraceIdFromCtx(ctx context.Context) (traceId string)

func Warn

func Warn(ctx context.Context, msg string, f Fields)

func WithTraceId

func WithTraceId(ctx context.Context, traceId string) context.Context

Types

type Fields

type Fields map[string]interface{}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL