mrlog

package
v0.15.3 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: Apache-2.0 Imports: 5 Imported by: 23

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseDateTimeFormat

func ParseDateTimeFormat(str string) (string, error)

func SetDefault

func SetDefault(logger Logger)

SetDefault - WARNING: use only when starting the main process

func WithContext

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

Types

type DefaultLogger

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

func New

func New(level Level) *DefaultLogger

func (*DefaultLogger) Debug

func (l *DefaultLogger) Debug() LoggerEvent

func (*DefaultLogger) Emit

func (l *DefaultLogger) Emit(ctx context.Context, eventName string, object any)

func (*DefaultLogger) EmitWithSource

func (l *DefaultLogger) EmitWithSource(ctx context.Context, eventName, source string, object any)

func (*DefaultLogger) Error

func (l *DefaultLogger) Error() LoggerEvent

func (*DefaultLogger) Fatal

func (l *DefaultLogger) Fatal() LoggerEvent

func (*DefaultLogger) Info

func (l *DefaultLogger) Info() LoggerEvent

func (*DefaultLogger) Level

func (l *DefaultLogger) Level() Level

func (*DefaultLogger) Panic

func (l *DefaultLogger) Panic() LoggerEvent

func (*DefaultLogger) Printf

func (l *DefaultLogger) Printf(format string, args ...any)

func (*DefaultLogger) Trace

func (l *DefaultLogger) Trace() LoggerEvent

func (*DefaultLogger) Warn

func (l *DefaultLogger) Warn() LoggerEvent

func (*DefaultLogger) With

func (l *DefaultLogger) With() LoggerContext

func (*DefaultLogger) WithContext

func (l *DefaultLogger) WithContext(ctx context.Context) context.Context

type Level

type Level int8
const (
	DebugLevel Level = iota
	InfoLevel
	WarnLevel
	ErrorLevel
	FatalLevel

	TraceLevel Level = -1
)

func ParseLevel

func ParseLevel(str string) (Level, error)

func (Level) String

func (e Level) String() string

type Logger

type Logger interface {
	Level() Level
	WithContext(ctx context.Context) context.Context

	With() LoggerContext

	Debug() LoggerEvent
	Info() LoggerEvent
	Warn() LoggerEvent
	Error() LoggerEvent
	Fatal() LoggerEvent
	Panic() LoggerEvent
	Trace() LoggerEvent

	Printf(format string, args ...any)
}

func Ctx

func Ctx(ctx context.Context) Logger

func Default

func Default() Logger

type LoggerContext

type LoggerContext interface {
	Logger() Logger

	CallerWithSkipFrame(count int) LoggerContext
	Str(key, value string) LoggerContext
	Bytes(key string, value []byte) LoggerContext
	Int(key string, value int) LoggerContext
	Any(key string, value any) LoggerContext
}

type LoggerEvent

type LoggerEvent interface {
	Caller(skip ...int) LoggerEvent
	CallerSkipFrame(skip int) LoggerEvent
	Err(err error) LoggerEvent
	Str(key, value string) LoggerEvent
	Bytes(key string, value []byte) LoggerEvent
	Int(key string, value int) LoggerEvent
	Any(key string, value any) LoggerEvent

	Msg(message string)
	Msgf(format string, args ...any)
	MsgFunc(createMsg func() string)
	Send()
}

type Options

type Options struct {
	Level           Level
	JsonFormat      bool
	TimestampFormat string
	ConsoleColor    bool

	// only if log level: Error, Fatal
	IsAutoCallerOnFunc func(err error) bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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