# README
zap
Under development.
Usage
import (
"github.com/uber-go/zap"
grpczap "github.com/eltorocorp/go-grpc-request-id-interceptor/zap"
"golang.org/x/net/context"
)
func main() {
logger = zap.New(zap.NewJSONEncoder())
uIntOpt := grpc.UnaryInterceptor(grpczap.UnaryServerInterceptor(logger))
sIntOpt := grpc.StreamInterceptor(grpczap.StreamServerInterceptor(logger))
grpc.NewServer(uIntOpt, sIntOpt)
}
Structured logging with context
import (
"github.com/uber-go/zap"
"github.com/eltorocorp/go-grpc-request-id-interceptor/zap/zapctx"
"golang.org/x/net/context"
)
func foo(ctx context.Context) {
// create new a context with some new zap.Field
newctx := zapctx.MustNewContextWith(ctx,
zap.String("user_id", 123456"),
)
// call other function with the context
bar(newctx)
}
func bar(ctx context.Context) {
// logging with additional context
logger := zapctx.MustFromContext(ctx)
logger.Info("message",
zap.String("function", "bar"),
)
}
# Packages
No description provided by the author
# Functions
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Variables
No description provided by the author
No description provided by the author