elog

package
v1.1.9 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2023 License: Apache-2.0 Imports: 11 Imported by: 5

Documentation

Index

Constants

View Source
const (
	KeyComponent     = "comp"
	KeyError         = "error"
	KeyTraceID       = "trace_id"
	KeySpanID        = "span_id"
	KeyEvent         = "event"
	KeyCost          = "duration"
	KeyDuration      = "duration"
	KeyMethod        = "method"
	KeyName          = "name"
	KeyAddr          = "addr"
	KeyRestyResponse = "resty_response"
	KeyReq           = "req"
	KeyResp          = "resp"
	KeyDetail        = "detail"
	KeySlow          = "slow"
)
View Source
const DefaultSkip = 2
View Source
const (
	Ezap = "ezap"
)

Variables

View Source
var (
	Logger        sync.Map
	DefaultLogger = ezap.NewConsoleEzap()
)

Functions

func AddCtxSkip

func AddCtxSkip(ctx context.Context, skip int) context.Context

func AppendCtxFields

func AppendCtxFields(ctx context.Context, fields ...zap.Field) context.Context

func DebugCtx

func DebugCtx(ctx context.Context, msg string, fields ...zap.Field)

func DelLogger

func DelLogger(name string)

DelLogger 删除日志插件

func ErrorCtx

func ErrorCtx(ctx context.Context, msg string, fields ...zap.Field)

func FieldAddr

func FieldAddr(v string) zap.Field

FieldAddr 设置 addr.

func FieldComponent

func FieldComponent(value string) zap.Field

FieldComponent 设置组件.

func FieldCost

func FieldCost(v time.Duration) zap.Field

FieldCost 设置 duration in ms.

func FieldDuration

func FieldDuration(v time.Duration) zap.Field

FieldCost 设置 duration in ms.

func FieldError

func FieldError(err error) zap.Field

FieldError 设置错误.

func FieldEvent

func FieldEvent(event string) zap.Field

FieldEvent 设置 event.

func FieldMethod

func FieldMethod(v string) zap.Field

FieldMethod 设置 method.

func FieldName

func FieldName(v string) zap.Field

FieldName 设置 name.

func FieldReq

func FieldReq(req interface{}) zap.Field

FieldReq 设置 req.

func FieldResp

func FieldResp(resp interface{}) zap.Field

FieldResp 设置 resp.

func FieldSlow

func FieldSlow(isSlow bool) zap.Field

FieldSlow 慢操作.

func FieldSpanID

func FieldSpanID(id string) zap.Field

FieldSpanID 设置 span id.

func FieldTrace

func FieldTrace(id string) zap.Field

FieldTrace 设置 trace id.

func GetCtxFields

func GetCtxFields(ctx context.Context) []zap.Field

func GetCtxSkip

func GetCtxSkip(ctx context.Context) int

func GetLoggerFromCtx

func GetLoggerFromCtx(ctx context.Context) logx.GLog

GetLoggerFromCtx

func InfoCtx

func InfoCtx(ctx context.Context, msg string, fields ...zap.Field)

func MakeReqResError

func MakeReqResError(callerSkip int, compName string, addr string, duration time.Duration, req string, err string) zap.Field

MakeReqResError 以error级别打印行号、配置名、目标地址、耗时、请求数据、响应数据

func MakeReqResInfo

func MakeReqResInfo(callerSkip int, compName string, addr string, duration time.Duration, req interface{}, reply interface{}) zap.Field

MakeReqResInfo 以info级别打印行号、配置名、目标地址、耗时、请求数据、响应数据

func MergeCtxFields

func MergeCtxFields(ctx context.Context, fields ...zap.Field) []zap.Field

func SetLogerName

func SetLogerName(ctx context.Context, name string) context.Context

func SetLogger

func SetLogger(name string, logger logx.GLog)

SetLogger 设置日志打印实例,选择输出到文件,终端,阿里云日志等

func WarnCtx

func WarnCtx(ctx context.Context, msg string, fields ...zap.Field)

Types

type CtxFieldKey

type CtxFieldKey struct{}

type CtxFieldsKey

type CtxFieldsKey struct{}

type CtxLogLevelKey

type CtxLogLevelKey struct{}

type CtxLoggerNameKey

type CtxLoggerNameKey struct{}

type CtxSkipKey

type CtxSkipKey struct{}

type LogLevel

type LogLevel int

LogLevel log level

const (
	// Silent silent log level
	Silent LogLevel = iota + 1
	// Error error log level
	Error
	// Warn warn log level
	Warn
	// Info info log level
	Info
	// Debug debug log level
	Debug
)

func (LogLevel) String

func (l LogLevel) String() string

String returns a lower-case ASCII representation of the log level.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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