1 Star 2 Fork 0

SkyWalking / go2sky-plugins

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
README.md 592 Bytes
一键复制 编辑 原始数据 按行查看 历史

Go2sky with zap (v1.16.0)

Installation

go get -u github.com/SkyAPM/go2sky-plugins/zap

Usage

package main

import (
	"context"
	
	zapplugin "github.com/SkyAPM/go2sky-plugins/zap"
	"go.uber.org/zap"
)

func main() {
	ctx := context.Background()
	logger := zap.NewExample()
	
	// You have two way to adopt
	// 1. Addition fields before logging
	logger.With(zapplugin.TraceContext(ctx)...).Info("test")
	
	// 2. Wrap logger and correlate context at logging
	logger = zapplugin.WrapWithContext(logger)
	logger.Info(ctx, "test")
}

See more.

Go
1
https://gitee.com/OpenSkywalking/go2sky-plugins.git
git@gitee.com:OpenSkywalking/go2sky-plugins.git
OpenSkywalking
go2sky-plugins
go2sky-plugins
v1.4.1

搜索帮助