logger

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2018 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FieldKeyTraceID = "trace_id"
	FieldKeyType    = "type"
	FieldKeyUserID  = "user_id"
)

定义日志中使用的键名

Variables

This section is empty.

Functions

func Access

func Access(traceID string, userID ...string) *logrus.Entry

Access 访问日志

func AccessWithContext

func AccessWithContext(ctx context.Context) *logrus.Entry

AccessWithContext 访问日志

func Login

func Login(traceID string, userID string) *logrus.Entry

Login 登录(登出)日志

func LoginWithContext

func LoginWithContext(ctx context.Context) *logrus.Entry

LoginWithContext 登录(登出)日志

func Middleware

func Middleware(allowPrefixes ...string) gin.HandlerFunc

Middleware GIN的日志中间件

func Operate

func Operate(traceID string, userID ...string) *logrus.Entry

Operate 操作日志

func OperateWithContext

func OperateWithContext(ctx context.Context) *logrus.Entry

OperateWithContext 操作日志

func System

func System(traceID string, userID ...string) *logrus.Entry

System 系统日志

func SystemWithContext

func SystemWithContext(ctx context.Context) *logrus.Entry

SystemWithContext 系统日志

Types

type HookFlusher

type HookFlusher interface {
	Flush()
}

HookFlusher 将缓冲区数据写入日志钩子完成接口

type Logger

type Logger struct {
	*logrus.Logger
}

Logger 日志管理

func Default

func Default() *Logger

Default 获取默认日志实例

func New

func New(opts ...Option) *Logger

New 创建日志实例

func (*Logger) Access

func (a *Logger) Access(traceID string, userID ...string) *logrus.Entry

Access 访问日志

func (*Logger) Login

func (a *Logger) Login(traceID string, userID string) *logrus.Entry

Login 登录(登出)日志

func (*Logger) Operate

func (a *Logger) Operate(traceID string, userID ...string) *logrus.Entry

Operate 操作日志

func (*Logger) System

func (a *Logger) System(traceID string, userID ...string) *logrus.Entry

System 系统日志

type Option

type Option func(o *options)

Option 定义配置参数

func SetFormat

func SetFormat(format string) Option

SetFormat 设定日志格式(text/json)

func SetLevel

func SetLevel(level int) Option

SetLevel 设定日志级别(0:panic,1:fatal,2:error,3:warn,4:info,5:debug)

Jump to

Keyboard shortcuts

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