uber-go/zap wrappers and tools.
go get -u github.com/na4ma4/go-zaptool
logger, _ := cfg.ZapConfig().Build()
ll := zaptool.NewLogLevels(logger)
processOne := server.NewProcess(ll.Named("Server.Process"))
// somewhere else.
ll.SetLevel("Server.Process", "debug")
// and triggered somewhere else again.
ll.SetLevel("Server.Process", "info")
logger, _ := zap.NewProduction()
defer logger.Sync() // flushes buffer, if any
r := mux.NewRouter()
r.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("This is a catch-all route"))
})
loggedRouter := zaptool.LoggingHTTPHandler(logger, r)
http.ListenAndServe(":1123", loggedRouter)