logger

package
v8.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TraceIDKey  = "trace_id"
	UserIDKey   = "user_id"
	UserNameKey = "user_name"
	TagKey      = "tag"
	StackKey    = "stack"
)

Define key

Variables

View Source
var (
	Tracef          = logrus.Tracef
	Debugf          = logrus.Debugf
	Infof           = logrus.Infof
	Warnf           = logrus.Warnf
	Errorf          = logrus.Errorf
	Fatalf          = logrus.Fatalf
	Panicf          = logrus.Panicf
	Printf          = logrus.Printf
	SetOutput       = logrus.SetOutput
	SetReportCaller = logrus.SetReportCaller
	StandardLogger  = logrus.StandardLogger
	ParseLevel      = logrus.ParseLevel
)

Define logrus alias

Functions

func AddHook

func AddHook(hook Hook)

AddHook Add logger hook

func FromStackContext

func FromStackContext(ctx context.Context) error

func FromTagContext

func FromTagContext(ctx context.Context) string

func FromTraceIDContext

func FromTraceIDContext(ctx context.Context) string

func FromUserIDContext

func FromUserIDContext(ctx context.Context) uint64

func FromUserNameContext

func FromUserNameContext(ctx context.Context) string

func NewStackContext

func NewStackContext(ctx context.Context, stack error) context.Context

func NewTagContext

func NewTagContext(ctx context.Context, tag string) context.Context

func NewTraceIDContext

func NewTraceIDContext(ctx context.Context, traceID string) context.Context

func NewUserIDContext

func NewUserIDContext(ctx context.Context, userID uint64) context.Context

func NewUserNameContext

func NewUserNameContext(ctx context.Context, userName string) context.Context

func SetFormatter

func SetFormatter(format string)

SetFormatter Set logger output format (json/text)

func SetLevel

func SetLevel(level Level)

SetLevel Set logger level

Types

type Entry

type Entry = logrus.Entry

Entry logrus.Entry alias

func WithContext

func WithContext(ctx context.Context) *Entry

WithContext Use context create entry

type Hook

type Hook = logrus.Hook

Hook logrus.Hook alias

type Level

type Level = logrus.Level
const (
	PanicLevel Level = iota
	FatalLevel
	ErrorLevel
	WarnLevel
	InfoLevel
	DebugLevel
	TraceLevel
)

Define logger level

type Logger

type Logger = logrus.Logger

Logger Logrus

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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