logger

package
v1.0.27 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TraceIDKey = "trace_id"
	UserIDKey  = "user_id"
	TagKey     = "tag"
	VersionKey = "version"
	StackKey   = "stack"
)

Define key

Variables

View Source
var (
	Trace  = logrus.Trace
	Tracef = logrus.Tracef
	Debug  = logrus.Debug
	Debugf = logrus.Debugf
	Info   = logrus.Info
	Infof  = logrus.Infof
	Warn   = logrus.Warn
	Warnf  = logrus.Warnf
	Error  = logrus.Error
	Errorf = logrus.Errorf
	Fatal  = logrus.Fatal
	Fatalf = logrus.Fatalf
	Panic  = logrus.Panic
	Panicf = logrus.Panicf
	Print  = logrus.Print
	Printf = logrus.Printf
)

Define logrus alias

Functions

func AddHook

func AddHook(hook Hook)

AddHook 增加日志钩子

func FromStackContext

func FromStackContext(ctx context.Context) error

FromStackContext 从上下文中获取Stack

func FromTagContext

func FromTagContext(ctx context.Context) string

FromTagContext 从上下文中获取Tag

func FromTraceIDContext

func FromTraceIDContext(ctx context.Context) string

FromTraceIDContext 从上下文中获取跟踪ID

func FromUserIDContext

func FromUserIDContext(ctx context.Context) string

FromUserIDContext 从上下文中获取用户ID

func NewStackContext

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

NewStackContext 创建Stack上下文

func NewTagContext

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

NewTagContext 创建Tag上下文

func NewTraceIDContext

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

NewTraceIDContext 创建跟踪ID上下文

func NewUserIDContext

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

NewUserIDContext 创建用户ID上下文

func SetFormatter

func SetFormatter(format string)

SetFormatter 设定日志输出格式

func SetLevel

func SetLevel(level int)

SetLevel 设定日志级别

func SetOutput

func SetOutput(out io.Writer)

SetOutput 设定日志输出

func SetVersion

func SetVersion(v string)

SetVersion 设定版本

Types

type Entry

type Entry = logrus.Entry

Entry Logrus enry

func WithContext

func WithContext(ctx context.Context) *Entry

WithContext Use context create entry

type Hook

type Hook = logrus.Hook

Hook 定义日志钩子别名

type Logger

type Logger = logrus.Logger

Logger Logrus

func StandardLogger

func StandardLogger() *Logger

StandardLogger 获取标准日志

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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