Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages