Skip to content

Sample Go code to demo the use of protobuf for logging

Notifications You must be signed in to change notification settings

amitmahbubani/protologs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

protologs

Protologs has sample Go code that demonstrates structured and strongly typed logging using Uber Zap and Protobuf.

This works by using a zap_marshaler protoc plugin that generates code from Proto messages that implements Zap's ObjectMarshaler interface. Proto generated structs can then be logged with zap.Object(&someProtoStruct{})

Proto definitions

Proto definitions for logs in /proto have base log context fields and service-specific field examples. These files are compiled to the /pkg/protolog directory with protoc.

protoc --zap-marshaler_out=./pkg/protolog --go_out=./pkg/protolog proto/protolog/*.proto

Examples

usersvc/main.go and paymentsvc/main.go are examples that both use a common base proto message, but different service-level proto messages.

Run with go run paymentsvc/main.go etc.

About

Sample Go code to demo the use of protobuf for logging

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages