interfaces

package
v2.0.16 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2022 License: Apache-2.0 Imports: 2 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DefaultAdapter     = AdapterTerm
	DefaultLevel       = LevelDebug
	DefaultTimeFormat  = "2006-01-02 15:04:05.999999"
	DefaultTraceId     = "X-B3-Traceid"
	DefaultSpanId      = "X-B3-Spanid"
	DefaultSpanVersion = "X-B3-Version"
	OpenTracingKey     = "OpenTracingKey"
)

Variables

View Source
var AdapterTexts = map[Adapter]string{
	AdapterTerm:  "TERM",
	AdapterFile:  "FILE",
	AdapterRedis: "REDIS",
}
View Source
var LevelTexts = map[Level]string{
	LevelOff:   "OFF",
	LevelError: "ERROR",
	LevelWarn:  "WARN",
	LevelInfo:  "INFO",
	LevelDebug: "DEBUG",
}

Functions

This section is empty.

Types

type Adapter

type Adapter int
const (
	AdapterOff Adapter = iota
	AdapterTerm
	AdapterFile
	AdapterRedis
)

type ClientInterface

type ClientInterface interface {
	// 添加Debug日志.
	Debug(text string)

	// 添加Debug日志, 支持格式化.
	Debugf(text string, args ...interface{})

	// 添加Debug日志, 支持格式化和请求链.
	Debugfc(ctx interface{}, text string, args ...interface{})

	// 添加Info日志.
	Info(text string)

	// 添加Info日志, 支持格式化.
	Infof(text string, args ...interface{})

	// 添加Info日志, 支持格式化和请求链.
	Infofc(ctx interface{}, text string, args ...interface{})

	// 添加Warn日志.
	Warn(text string)

	// 添加Warn日志, 支持格式化.
	Warnf(text string, args ...interface{})

	// 添加Warn日志, 支持格式化和请求链.
	Warnfc(ctx interface{}, text string, args ...interface{})

	// 添加Error日志.
	Error(text string)

	// 添加Error日志, 支持格式化.
	Errorf(text string, args ...interface{})

	// 添加Error日志, 支持格式化和请求链.
	Errorfc(ctx interface{}, text string, args ...interface{})

	Panic(text string)
	Panicf(text string, args ...interface{})
	Panicfc(ctx interface{}, text string, args ...interface{})
}

客户端接口

type ConfigInterface

type ConfigInterface interface {
	AppAddr() string
	AppName() string
	DebugOn() bool
	ErrorOn() bool
	GetHandler() Handler
	GetLevel(level Level) string
	GetPid() int
	GetTimeFormat() string
	GetTrace() (traceId string, spanId string, spanVersion string)
	InfoOn() bool
	LoadYaml(string) error
	SetAdapter(string) ConfigInterface
	SetHandler(Handler) ConfigInterface
	SetLevel(string) ConfigInterface
	SetTimeFormat(string) ConfigInterface
	WarnOn() bool
}

Config interface.

type Handler

type Handler func(LineInterface)

Handler.

type Level

type Level int
const (
	LevelOff Level = iota
	LevelError
	LevelWarn
	LevelInfo
	LevelDebug
)

type LineInterface

type LineInterface interface {
	ColorLevel() string
	Content() string
	Duration() float64
	Level() string
	ParentSpanId() string
	Pid() int
	RequestInfo() (method string, url string)
	ServiceAddr() string
	ServiceName() string
	SpanId() string
	SpanVersion() string
	Time() time.Time
	Timeline() string
	TraceId() string
	Tracing() bool
}

type TraceInterface

type TraceInterface interface {
	GenCurrentVersion() string
	GenPreviewVersion() string
	GenVersion(i int32) string
	GetParentSpanId() string
	GetSpanId() string
	GetSpanVersion() string
	GetTraceId() string
	IncrOffset() (before int32, after int32)
	RequestInfo() (method string, url string)
	Use(traceId, spanVersion string) TraceInterface
	UseDefault() TraceInterface
	UseRequest(req *http.Request) TraceInterface
}

Jump to

Keyboard shortcuts

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