log

package
v0.0.0-...-57f014e Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BatchSize = 100 * 1024
	Frequency = 1 * time.Second
)
View Source
const (
	SpanKey = "span"
)

Variables

This section is empty.

Functions

func Close

func Close()

func CtxAddKv

func CtxAddKv(ctx context.Context, v ...interface{}) context.Context

func CtxDebugf

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

func CtxErrorf

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

func CtxFatalf

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

func CtxInfof

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

func CtxPanicf

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

func CtxWarnf

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

func Debug

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

func Debugf

func Debugf(format string, args ...interface{})

func EnableAsyncLog

func EnableAsyncLog()

func Error

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

func Errorf

func Errorf(format string, args ...interface{})

func Fatalf

func Fatalf(format string, args ...interface{})

func GetLocalIP

func GetLocalIP() string

GetLocalIP 获取本机ip地址

func Info

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

func Infof

func Infof(format string, args ...interface{})

func NewChildSpan

func NewChildSpan(ctx context.Context) context.Context

func NewCore

func NewCore(enc zapcore.Encoder, ws zapcore.WriteSyncer, enab zapcore.LevelEnabler) *asyncCore

NewCore creates a Core that writes logs to a WriteSyncer.

func Panic

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

func Panicf

func Panicf(format string, args ...interface{})

func Pb

func Pb(key string, pbMsg proto.Message) zap.Field

func Start

func Start(logPath string)

func StartWithConfig

func StartWithConfig(config *Config)

func StartWithLevel

func StartWithLevel(logPath string, level zapcore.Level)

func Warn

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

func Warnf

func Warnf(format string, args ...interface{})

func WithField

func WithField(f ...zapcore.Field)

func WithSpan

func WithSpan(ctx context.Context) context.Context

WithSpan 检查ctx中是否有span信息,如没有则创建span信息

Types

type Config

type Config struct {
	FileName   string
	MaxSize    int
	MaxAge     int
	MaxBackups int
	Compress   bool

	// 采样配置
	Tick       time.Duration
	First      int
	Thereafter int
	Level      zapcore.Level
}

type SampleLogger

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

func NewSampleLogger

func NewSampleLogger(config *Config) *SampleLogger

func (*SampleLogger) Info

func (logger *SampleLogger) Info(ctx context.Context, msg string, fields ...zap.Field)

type Span

type Span struct {
	TraceID      string `json:"trace_id"`
	SpanID       string `json:"span_id"`
	ParentSpanID string `json:"parent_span_id"`
}

func NewSpan

func NewSpan() *Span

NewSpan 创建新的span信息

func SpanFromContext

func SpanFromContext(ctx context.Context) *Span

SpanFromContext 从ctx中读取span信息

Jump to

Keyboard shortcuts

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