Skip to content
This repository has been archived by the owner on Jun 14, 2023. It is now read-only.

Latest commit

 

History

History
35 lines (25 loc) · 592 Bytes

README.md

File metadata and controls

35 lines (25 loc) · 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.