zlog

package
v0.0.0-...-3cf0c3c Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 13 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// TraceIDKey 跟踪ID
	TraceIDKey = "trace_id"
	// SpanIDKey 请求ID
	SpanIDKey = "span_id"
	// UserIDKey 用户ID
	UserIDKey = "user_id"
)
View Source
const (
	// XTraceIDKey ...
	XTraceIDKey = "X-Trace-Id"
	// XSpanIDKey ...
	XSpanIDKey = "X-Span-Id"
)

Variables

View Source
var (
	Standard *zap.Logger
	Sugared  *zap.SugaredLogger
)

Functions

func CopyContext

func CopyContext(ctx context.Context) context.Context

CopyContext copy context

func FromSpanIDContext

func FromSpanIDContext(ctx context.Context) (spanID string, ok bool)

FromSpanIDContext ...

func FromTraceIDContext

func FromTraceIDContext(ctx context.Context) (traceID string, ok bool)

FromTraceIDContext ...

func FromUserIDContext

func FromUserIDContext(ctx context.Context) (userID string, ok bool)

FromUserIDContext ...

func Init

func Init(opts ...Option)

func InitForViper

func InitForViper(conf *viper.Viper)

func NewSpanIDContext

func NewSpanIDContext(ctx context.Context, spanID string) context.Context

NewSpanIDContext ...

func NewTraceIDContext

func NewTraceIDContext(ctx context.Context, traceID string) context.Context

NewTraceIDContext ...

func NewUserIDContext

func NewUserIDContext(ctx context.Context, userID string) context.Context

NewUserIDContext ...

func NewZincSink

func NewZincSink(uri *url.URL) (zs zap.Sink, err error)

NewZincSink zinc://username:password@localhost:4080/index?format=json

func RegisterSink

func RegisterSink()

func Sync

func Sync()

func With

func With(ctx context.Context) *zap.Logger

func WithGrpcMetadata

func WithGrpcMetadata(ctx context.Context, userID string) context.Context

WithGrpcMetadata 从上下文中

func WithRequestContext

func WithRequestContext(req *http.Request, userID string) context.Context

WithRequestContext ...

func WithSugared

func WithSugared(ctx context.Context) *zap.SugaredLogger

Types

type ContextSpanIDKey

type ContextSpanIDKey struct{}

type ContextTraceIDKey

type ContextTraceIDKey struct{}

type ContextUserIDKey

type ContextUserIDKey struct{}

type Option

type Option func(o *Options)

func WithConfig

func WithConfig(conf zap.Config) Option

type Options

type Options struct {
	Config zap.Config
}

type SqlxplusLogger

type SqlxplusLogger struct {
}

SqlxplusLogger ...

func (SqlxplusLogger) Errorf

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

Errorf 错误

func (SqlxplusLogger) Errorln

func (SqlxplusLogger) Errorln(ctx context.Context, args ...interface{})

Errorln 错误

func (SqlxplusLogger) Printf

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

Printf 打印

func (SqlxplusLogger) Println

func (SqlxplusLogger) Println(ctx context.Context, args ...interface{})

Println 打印

type ZincSink

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

func (*ZincSink) Close

func (zs *ZincSink) Close() (err error)

func (*ZincSink) Sync

func (zs *ZincSink) Sync() (err error)

func (*ZincSink) Write

func (zs *ZincSink) Write(p []byte) (n int, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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