logger

package
v1.1.97 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CommonLogXFields = "common-log-x-fields"
	XUID             = "x-uid"
	XRequestID       = "x-request-id"
	XRequestMethod   = "x-request-method"
	XRequestURI      = "x-request-uri"
	XRequestPath     = "x-request-path"
	XUserAgent       = "x-ua"
	XClientIP        = "x-client-ip"
)

ctx common log key

View Source
const (
	KeyReturnCode = "x-return-code"
	CtxUser       = "x-user"
)

Variables

DB 记录log到db中

View Source
var Logger *zap.Logger

Logger 全局 Logger 对象

Functions

func Debug

func Debug(ctx context.Context, msg string, args ...interface{})

Debug Debug

func Error

func Error(ctx context.Context, msg string, args ...interface{})

Error Error

func Info

func Info(ctx context.Context, msg string, args ...interface{})

Info Info

func Init added in v1.1.42

func Init(filename string, maxSize, maxBackup, maxAge int, compress bool, logType string, level string)

Init 日志初始化

func InitByConfig added in v1.1.42

func InitByConfig()

InitByConfig 根据config配置初始化日志

func LogIf

func LogIf(ctx context.Context, err error)

LogIf 当 err != nil 时记录 error 等级的日志

func LogInfoIf

func LogInfoIf(ctx context.Context, err error)

LogInfoIf 当 err != nil 时记录 info 等级的日志

func LogWarnIf

func LogWarnIf(ctx context.Context, err error)

LogWarnIf 当 err != nil 时记录 warning 等级的日志

func Recover added in v1.1.34

func Recover(ctx context.Context)

Recover 捕获panic

func SetLogXFields added in v1.1.34

func SetLogXFields(ctx context.Context, keyValues map[string]string) context.Context

SetLogXFields 上下文设置通用日志x字段

func Warn

func Warn(ctx context.Context, msg string, args ...interface{})

Warn Warn

Types

This section is empty.

Jump to

Keyboard shortcuts

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