logger

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2022 License: MIT Imports: 14 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TimeFormat = "2006-01-02T15:04:05.999Z07:00"
View Source
var TracingHandle = Handle(func(ctx context.Context, e entry.Entry) []entry.Field {
	trac := tracing.FromContextOrNew(ctx)
	return []entry.Field{
		WithField("tracingId", trac.Id),
		WithField("tracingSpanId", trac.SpanId),
		WithField("tracingStepSize", trac.StepSize),
		WithField("tracingStartTime", trac.StartTime.Format(TimeFormat)),
		WithField("tracingEndTime", time.Now().Format(TimeFormat)),
		WithField("tracingParentSpanId", trac.ParentSpanId),
		WithField("tracingParentStepSize", trac.ParentStepSize),
		WithField("tracingDuration", time.Since(trac.StartTime).Milliseconds()),
	}
})

Functions

func AddHandle

func AddHandle(ctx context.Context, handle Handle)

func Bootstrap

func Bootstrap(ctx context.Context, configBody []byte) error

Bootstrap init logger config

func Debug

func Debug(ctx context.Context, tag string, fields ...entry.Field)

func Error

func Error(ctx context.Context, tag string, err error, fields ...entry.Field)

func Fatal

func Fatal(ctx context.Context, tag string, err error, fields ...entry.Field)

func GetStack

func GetStack(skip int, depth int) string

func Info

func Info(ctx context.Context, tag string, fields ...entry.Field)

func Notice

func Notice(ctx context.Context, tag string, fields ...entry.Field)

func SetLogger

func SetLogger(l Logger)

SetLogger set global logger

func Trace

func Trace(ctx context.Context, tag string, fields ...entry.Field)

func Warning

func Warning(ctx context.Context, tag string, err error, fields ...entry.Field)

func WithField

func WithField(key string, value interface{}) entry.Field

Types

type BootstrapConfig

type BootstrapConfig struct {
	Level       string `json:"level" yaml:"level"`
	QueueLength int    `yaml:"queueLength"`
	Dispatchers []struct {
		Type      string            `json:"type" yaml:"type"`
		Formatter string            `json:"formatter" yaml:"formatter"`
		Tags      []string          `json:"tags" yaml:"tags"`
		Settings  map[string]string `json:"settings" yaml:"settings"`
	} `json:"dispatchers" yaml:"dispatchers"`
}

type Handle

type Handle func(ctx context.Context, e entry.Entry) []entry.Field

type Logger

type Logger interface {
	Fatal(ctx context.Context, tag string, err error, fields ...entry.Field)

	Error(ctx context.Context, tag string, err error, fields ...entry.Field)

	Warning(ctx context.Context, tag string, err error, fields ...entry.Field)

	Info(ctx context.Context, tag string, fields ...entry.Field)

	Notice(ctx context.Context, tag string, fields ...entry.Field)

	Debug(ctx context.Context, tag string, fields ...entry.Field)

	Trace(ctx context.Context, tag string, fields ...entry.Field)

	SetLevel(level.Level)

	Flush()

	AddDispatcher(dispatchers ...dispatcher.Dispatcher)

	AddHandle(ctx context.Context, handle Handle)

	Stop()
}

func GetLogger

func GetLogger() Logger

GetLogger get global logger

func NewLogger

func NewLogger(ctx context.Context, queueLength int) Logger

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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