zaputil

package
v0.5.9 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EncoderConfig = zapcore.EncoderConfig{

	MessageKey:     "message",
	LevelKey:       "severity",
	TimeKey:        "timestamp",
	NameKey:        "logger",
	CallerKey:      "caller",
	StacktraceKey:  "stacktrace",
	LineEnding:     zapcore.DefaultLineEnding,
	EncodeLevel:    EncodeLevel,
	EncodeTime:     RFC3339NanoTimeEncoder,
	EncodeDuration: zapcore.SecondsDurationEncoder,
	EncodeCaller:   zapcore.ShortCallerEncoder,
}

encoderConfig is the default encoder configuration, slightly tweaked to use the correct fields for Stackdriver to parse them.

Functions

func EncodeLevel

func EncodeLevel(l zapcore.Level, enc zapcore.PrimitiveArrayEncoder)

EncodeLevel maps the internal Zap log level to the appropriate Stackdriver level.

func GRPCCodeToLevel

func GRPCCodeToLevel(code codes.Code) zapcore.Level

GRPCCodeToLevel is the mapping of gRPC return codes and interceptor log level. Convert codes.OK to DEBUG level, the rest are the same with the DefaultCodeToLevel in grpc_zap.

func GRPCZapLogger

func GRPCZapLogger(logger log.Logger) (*zap.Logger, error)

GRPCZapLogger returns *zap.Logger from salt/log.Logger. if error, returns a new *zap.Logger instance

func RFC3339NanoTimeEncoder

func RFC3339NanoTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)

RFC3339NanoTimeEncoder serializes a time.Time to an RFC3339Nano-formatted string with nanoseconds precision.

func ServiceContext

func ServiceContext(name string) zap.Field

ServiceContext adds the correct service information adding the log line It is a required field if an error needs to be reported. See Service context and formatting error message

Types

This section is empty.

Jump to

Keyboard shortcuts

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