log

package
v0.0.0-...-26e86c7 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoLogger = errors.New("no logger available")
)

Functions

func Debug

func Debug(msg string, opts ...Options) error

func Error

func Error(msg string, opts ...Options) error

func Fatal

func Fatal(msg string, opts ...Options) error

func FieldsFromContext

func FieldsFromContext(ctx context.Context) map[string]interface{}

func Info

func Info(msg string, opts ...Options) error

func InjectContext

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

func InjectFieldsContext

func InjectFieldsContext(ctx context.Context, fields map[string]interface{}) context.Context

func SetDefault

func SetDefault(logger Logger)

func SetLevel

func SetLevel(level Level)

func Trace

func Trace(msg string, opts ...Options) error

func Warning

func Warning(msg string, opts ...Options) error

Types

type ChainLogger

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

func (*ChainLogger) Close

func (l *ChainLogger) Close(ctx context.Context) error

func (*ChainLogger) Init

func (l *ChainLogger) Init(ctx context.Context, c config.Config) error

func (*ChainLogger) Log

func (l *ChainLogger) Log(level Level, msg *MessageLog)

func (*ChainLogger) SetLevel

func (l *ChainLogger) SetLevel(level Level)

type Config

type Config struct {
	Level int `mapstructure:"level"`
}

Config hold logger configuration

func LoadConfig

func LoadConfig(c config.Config) Config

LoadConfig help you to load logger's config from the general config

type Level

type Level int
const (
	FatalLevel Level = iota
	ErrorLevel
	WarningLevel
	InfoLevel
	DebugLevel
	TraceLevel
)

type Logger

type Logger interface {
	api.Module
	SetLevel(level Level)
	Log(level Level, msg *MessageLog)
}

Logger represent any logging capable

func Default

func Default() Logger

func FromContext

func FromContext(ctx context.Context) Logger

type LoggerFactory

type LoggerFactory func() Logger

type LogrusLogger

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

func NewLogrusLogger

func NewLogrusLogger() *LogrusLogger

func (*LogrusLogger) Close

func (l *LogrusLogger) Close(ctx context.Context) error

func (*LogrusLogger) Init

func (l *LogrusLogger) Init(ctx context.Context, c config.Config) error

func (*LogrusLogger) Log

func (l *LogrusLogger) Log(level Level, msg *MessageLog)

func (*LogrusLogger) SetLevel

func (l *LogrusLogger) SetLevel(level Level)

type MessageLog

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

MessageLog hold message to be logged

type Option

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

type Options

type Options interface {
	Configure(o *Option)
}

func WithContext

func WithContext(ctx context.Context) Options

WithContext decorate current message option to include a context maybe override the logger option

func WithError

func WithError(err error) Options

WithTime decorate message option that override the error

func WithField

func WithField(key string, value interface{}) Options

WithField add a single field to the message option

func WithFields

func WithFields(fields map[string]interface{}) Options

WithFileds adds all parameter fields for decorate current message option

func WithLogger

func WithLogger(logger Logger) Options

WithLogger decorate message option to use specific logger

func WithTime

func WithTime(t time.Time) Options

WithTime decorate message option that override default now timestamp

func WithValues

func WithValues(v ...interface{}) Options

WithValues decorate message option to use Printf style formatting

type OptionsFunc

type OptionsFunc func(o *Option)

func (OptionsFunc) Configure

func (f OptionsFunc) Configure(o *Option)

Jump to

Keyboard shortcuts

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