log

package module
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2023 License: MIT Imports: 9 Imported by: 9

README

log

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init added in v0.2.0

func Init(dsn string)

func NewTraceContext added in v0.2.0

func NewTraceContext(traceID string) context.Context

NewTraceContext new context with a traceID

func WithContext added in v0.2.0

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

WithContext 从指定的context返回一个zap实例(关键方法)

Types

type Config added in v0.2.0

type Config struct {
	Encoder    string   // 编码器: console, json
	Outputs    []string // 日志输出方式 stdout, file
	Parameters struct {
		Level         string // level 日志输出级别: e.g. debug, info, warn, error
		TraceLevel    string // trace_level 是否开启错误上下文追踪
		TimeEncoder   string // time_encoder 时间编码器(时间格式)
		CallerEncoder string // caller_encoder 调用者格式 e.g. short, full
		FilePath      string // file_path output包含file时需要此参数
	}
}

Config config

func ParseConfig added in v0.2.0

func ParseConfig(dsn string) (*Config, error)

ParseConfig parse config from dsn dsn e.g. console://[stdout,file]?level=debug&trace_level=error

type Logger added in v0.2.0

type Logger struct {
	ZapLogger *zap.Logger
}
var DefaultLogger *Logger

DefaultLogger default logger

func New added in v0.2.0

func New(dsn string) (*Logger, error)

func (*Logger) WithContext added in v0.2.0

func (receiver *Logger) WithContext(ctx context.Context) *zap.Logger

type TraceIDKeyType added in v0.2.0

type TraceIDKeyType string

TraceIDKeyType trace id key type

const (
	// TraceIDKey trace id key
	TraceIDKey TraceIDKeyType = "traceId"
)

Jump to

Keyboard shortcuts

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