log

package
v0.0.0-...-acd4c60 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2021 License: MIT Imports: 18 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendNotice

func AppendNotice(ctx context.Context, keysAndValues ...interface{})

func BaggageFlowField

func BaggageFlowField(ctx context.Context) (f zap.Field)

BaggageFlowField Todo: get baggage flow

func ExtFields

func ExtFields(ctx context.Context) (fs []zap.Field)

func GetGid

func GetGid() int64

func IsSecrecyMsg

func IsSecrecyMsg(msg string) bool

func L

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

func New

func New(conf Config) (*zap.Logger, error)

func S

func Set

func Set(conf Config) (func(), error)

func SpanIDField

func SpanIDField(ctx context.Context) zap.Field

func TraceIdField

func TraceIdField(ctx context.Context) (f zap.Field)

Types

type ByteMarshaler

type ByteMarshaler struct {
	Key  string
	Data []byte
}

func (*ByteMarshaler) MarshalJSON

func (j *ByteMarshaler) MarshalJSON() ([]byte, error)

func (*ByteMarshaler) MarshalLogObject

func (j *ByteMarshaler) MarshalLogObject(e zapcore.ObjectEncoder) error

type Config

type Config struct {
	ServiceName string `yaml:"serviceName"`
	// 日志级别.
	Level string `yaml:"level"`
	// Log format. one of json or plain.
	Format string `yaml:"format"`
	// 是否输出到控制台.
	Stdout bool `yaml:"stdout"`
	// File log config.
	File FileLogConfig `yaml:"file"`
}

Config serializes log related config in toml/json.

type FileLogConfig

type FileLogConfig struct {
	// 日志文件路径.
	Filename string `yaml:"filename"`
	// Is log rotate enabled.
	LogRotate bool `yaml:"logRotate"`
	// Max size for a single file, in MB.
	MaxSize int `yaml:"maxSize"`
	// Max log keep days, default is never deleting.
	MaxDays int `yaml:"maxDays"`
	// Maximum number of old log files to retain.
	MaxBackups int `yaml:"maxBackups"`
	// MAX size of bufio.Writer
	BufSize int `yaml:"bufSize"`
}

FileLogConfig serializes file log related config.

type JsonMarshaler

type JsonMarshaler struct {
	Key  string
	Data interface{}
}

func (*JsonMarshaler) MarshalJSON

func (j *JsonMarshaler) MarshalJSON() ([]byte, error)

func (*JsonMarshaler) MarshalLogObject

func (j *JsonMarshaler) MarshalLogObject(e zapcore.ObjectEncoder) error

func (*JsonMarshaler) NeedKeepSecrecy

func (j *JsonMarshaler) NeedKeepSecrecy() bool

Directories

Path Synopsis
Package grpczap provides a logger that is compatible with grpclog.
Package grpczap provides a logger that is compatible with grpclog.

Jump to

Keyboard shortcuts

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