logger

package
v6.4.4 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TraceIDKey      = "trace_id"
	UserIDKey       = "user_id"
	SpanTitleKey    = "span_title"
	SpanFunctionKey = "span_function"
	VersionKey      = "version"
	StackKey        = "stack"
)

定义键名

Variables

This section is empty.

Functions

func AddHook

func AddHook(hook Hook)

AddHook 增加日志钩子

func Debugf

func Debugf(ctx context.Context, format string, args ...interface{})

Debugf 写入调试日志

func ErrorStack added in v6.4.0

func ErrorStack(ctx context.Context, err error)

ErrorStack 输出错误栈

func Errorf

func Errorf(ctx context.Context, format string, args ...interface{})

Errorf 写入错误日志

func Fatalf

func Fatalf(ctx context.Context, format string, args ...interface{})

Fatalf 写入重大错误日志

func FromTraceIDContext

func FromTraceIDContext(ctx context.Context) string

FromTraceIDContext 从上下文中获取跟踪ID

func FromUserIDContext

func FromUserIDContext(ctx context.Context) string

FromUserIDContext 从上下文中获取用户ID

func Infof

func Infof(ctx context.Context, format string, args ...interface{})

Infof 写入消息日志

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 Printf

func Printf(ctx context.Context, format string, args ...interface{})

Printf 写入消息日志

func SetFormatter

func SetFormatter(format string)

SetFormatter 设定日志输出格式

func SetLevel

func SetLevel(level int)

SetLevel 设定日志级别

func SetOutput

func SetOutput(out io.Writer)

SetOutput 设定日志输出

func SetTraceIDFunc

func SetTraceIDFunc(fn TraceIDFunc)

SetTraceIDFunc 设定追踪ID的处理函数

func SetVersion

func SetVersion(v string)

SetVersion 设定版本

func Warnf

func Warnf(ctx context.Context, format string, args ...interface{})

Warnf 写入警告日志

Types

type Entry

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

Entry 定义统一的日志写入方式

func StartSpan

func StartSpan(ctx context.Context, opts ...SpanOption) *Entry

StartSpan 开始一个追踪单元

func (*Entry) Debugf

func (e *Entry) Debugf(format string, args ...interface{})

Debugf 写入调试日志

func (*Entry) Errorf

func (e *Entry) Errorf(format string, args ...interface{})

Errorf 错误日志

func (*Entry) Fatalf

func (e *Entry) Fatalf(format string, args ...interface{})

Fatalf 重大错误日志

func (*Entry) Infof

func (e *Entry) Infof(format string, args ...interface{})

Infof 消息日志

func (*Entry) Printf

func (e *Entry) Printf(format string, args ...interface{})

Printf 消息日志

func (*Entry) Warnf

func (e *Entry) Warnf(format string, args ...interface{})

Warnf 警告日志

func (*Entry) WithField

func (e *Entry) WithField(key string, value interface{}) *Entry

WithField 结构化字段写入

func (*Entry) WithFields

func (e *Entry) WithFields(fields map[string]interface{}) *Entry

WithFields 结构化字段写入

type Hook

type Hook = logrus.Hook

Hook 定义日志钩子别名

type Logger

type Logger = logrus.Logger

Logger 定义日志别名

func StandardLogger

func StandardLogger() *Logger

StandardLogger 获取标准日志

type SpanOption

type SpanOption func(*spanOptions)

SpanOption 定义跟踪单元的数据项

func SetSpanFuncName

func SetSpanFuncName(funcName string) SpanOption

SetSpanFuncName 设置跟踪单元的函数名

func SetSpanTitle

func SetSpanTitle(title string) SpanOption

SetSpanTitle 设置跟踪单元的标题

type TraceIDFunc

type TraceIDFunc func() string

TraceIDFunc 定义获取跟踪ID的函数

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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