util

package
v0.0.0-...-d1be498 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Deref

func Deref[T any](p *T, defaultValue T) T

func InitGLogger

func InitGLogger(options ...loggerOption)

func NewContextWithLogger

func NewContextWithLogger(ctx context.Context, logger Logger) context.Context

func ToPointer

func ToPointer[T any](v T) *T

Types

type Logger

type Logger interface {
	Enabled() bool
	WithValues(keysAndValues ...interface{}) Logger
	Debug(msg string, keysAndValues ...interface{})
	Info(msg string, keysAndValues ...interface{})
	Warn(err error, msg string, keysAndValues ...interface{})
	Error(err error, msg string, keysAndValues ...interface{})
	WithCallDepth(depth int) Logger
	WithName(name string) Logger
	Begin(name string, msg string, keysAndValues ...interface{}) func(msg string, keysAndValues ...interface{})
}

func FromContext

func FromContext(ctx context.Context) Logger

func GLogger

func GLogger() Logger

func NewLoggerStdImplWithOption

func NewLoggerStdImplWithOption() Logger

func NewLoggerZapImplWithOption

func NewLoggerZapImplWithOption(options ...loggerOption) (Logger, error)

type LoggerFormat

type LoggerFormat int
const (
	LoggerFormatJSON LoggerFormat = iota
	LoggerFormatConsole
)

func ParseLoggerFormatStr

func ParseLoggerFormatStr(v string) LoggerFormat

func (LoggerFormat) String

func (f LoggerFormat) String() string

type LoggerFormatOption

type LoggerFormatOption int

func OptionLoggerFormat

func OptionLoggerFormat(v LoggerFormat) LoggerFormatOption

type LoggerLevel

type LoggerLevel int
const (
	LoggerLevelDebug LoggerLevel = iota - 1
	LoggerLevelInfo
	LoggerLevelWarn
	LoggerLevelError
)

func ParseLoggerLevelStr

func ParseLoggerLevelStr(v string) LoggerLevel

func (LoggerLevel) String

func (l LoggerLevel) String() string

type LoggerLevelOption

type LoggerLevelOption int

func OptionLoggerLevel

func OptionLoggerLevel(v LoggerLevel) LoggerLevelOption

type LoggerStdImpl

type LoggerStdImpl struct {
	// contains filtered or unexported fields
}

func (*LoggerStdImpl) Begin

func (l *LoggerStdImpl) Begin(name string, msg string, keysAndValues ...interface{}) func(msg string, keysAndValues ...interface{})

func (*LoggerStdImpl) Debug

func (l *LoggerStdImpl) Debug(msg string, keysAndValues ...interface{})

func (*LoggerStdImpl) Enabled

func (l *LoggerStdImpl) Enabled() bool

func (*LoggerStdImpl) Error

func (l *LoggerStdImpl) Error(err error, msg string, keysAndValues ...interface{})

func (*LoggerStdImpl) Info

func (l *LoggerStdImpl) Info(msg string, keysAndValues ...interface{})

func (*LoggerStdImpl) Warn

func (l *LoggerStdImpl) Warn(err error, msg string, keysAndValues ...interface{})

func (*LoggerStdImpl) WithCallDepth

func (l *LoggerStdImpl) WithCallDepth(depth int) Logger

func (*LoggerStdImpl) WithName

func (l *LoggerStdImpl) WithName(name string) Logger

func (*LoggerStdImpl) WithValues

func (l *LoggerStdImpl) WithValues(keysAndValues ...interface{}) Logger

type LoggerZapImpl

type LoggerZapImpl struct {
	// contains filtered or unexported fields
}

func (*LoggerZapImpl) Begin

func (l *LoggerZapImpl) Begin(name string, msg string, keysAndValues ...interface{}) func(msg string, keysAndValues ...interface{})

func (*LoggerZapImpl) Debug

func (l *LoggerZapImpl) Debug(msg string, keysAndValues ...interface{})

func (*LoggerZapImpl) Enabled

func (l *LoggerZapImpl) Enabled() bool

func (*LoggerZapImpl) Error

func (l *LoggerZapImpl) Error(err error, msg string, keysAndValues ...interface{})

func (*LoggerZapImpl) Info

func (l *LoggerZapImpl) Info(msg string, keysAndValues ...interface{})

func (*LoggerZapImpl) Warn

func (l *LoggerZapImpl) Warn(err error, msg string, keysAndValues ...interface{})

func (*LoggerZapImpl) WithCallDepth

func (l *LoggerZapImpl) WithCallDepth(depth int) Logger

func (*LoggerZapImpl) WithName

func (l *LoggerZapImpl) WithName(name string) Logger

func (*LoggerZapImpl) WithValues

func (l *LoggerZapImpl) WithValues(keysAndValues ...interface{}) Logger

Jump to

Keyboard shortcuts

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