zapgrpc2

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2019 License: MIT Imports: 5 Imported by: 0

README

Documentation

Overview

Package zapgrpc2 provides a logger that is compatible with grpclog.

Index

Constants

This section is empty.

Variables

View Source
var DefaultLogLevel = "info"
View Source
var DefaultZapLoggerConfig = zap.Config{
	Level: zap.NewAtomicLevelAt(ConvertToZapLevel(DefaultLogLevel)),

	Development: false,
	Sampling: &zap.SamplingConfig{
		Initial:    100,
		Thereafter: 100,
	},

	Encoding: "json",

	EncoderConfig: zapcore.EncoderConfig{
		TimeKey:        "ts",
		LevelKey:       "level",
		NameKey:        "logger",
		CallerKey:      "caller",
		MessageKey:     "msg",
		StacktraceKey:  "stacktrace",
		LineEnding:     zapcore.DefaultLineEnding,
		EncodeLevel:    zapcore.LowercaseLevelEncoder,
		EncodeTime:     zapcore.ISO8601TimeEncoder,
		EncodeDuration: zapcore.StringDurationEncoder,
		EncodeCaller:   zapcore.ShortCallerEncoder,
	},

	OutputPaths:      []string{"stderr"},
	ErrorOutputPaths: []string{"stderr"},
}

DefaultZapLoggerConfig defines default zap logger configuration.

Functions

func AddOutputPaths added in v0.4.2

func AddOutputPaths(cfg zap.Config, outputPaths, errorOutputPaths []string) zap.Config

AddOutputPaths adds output paths to the existing output paths, resolving conflicts.

func ConvertToZapLevel added in v0.4.2

func ConvertToZapLevel(lvl string) zapcore.Level

ConvertToZapLevel converts log level string to zapcore.Level.

func NewGRPCLoggerV2 added in v0.4.2

func NewGRPCLoggerV2(lcfg zap.Config) (grpclog.LoggerV2, error)

NewGRPCLoggerV2 converts "*zap.Logger" to "grpclog.LoggerV2". It discards all INFO level logging in gRPC, if debug level is not enabled in "*zap.Logger".

func NewGRPCLoggerV2FromZapCore added in v0.4.2

func NewGRPCLoggerV2FromZapCore(cr zapcore.Core, syncer zapcore.WriteSyncer) grpclog.LoggerV2

NewGRPCLoggerV2FromZapCore creates "grpclog.LoggerV2" from "zap.Core" and "zapcore.WriteSyncer". It discards all INFO level logging in gRPC, if debug level is not enabled in "*zap.Logger".

Types

This section is empty.

Jump to

Keyboard shortcuts

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