Golang global logging using uber zap

so you want to use the logger from go.uber.org/zap globally, and there are several ways of doing it: (for shortest way jump to #4)

(just too many to pass it down and you know how)

func main() {
logger, _ := zap.NewProduction()
otherPackage1.Logger = logger
otherPackage2.Logger = logger
.... // tedious >_<
}
// other package
package otherPackage1
var Logger *zap.Logger
...
func…

--

--

love writing bit sized programming memo, acoustic guitarist, proud daddy of 5 and great listener (to my kids)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Jim Kang

love writing bit sized programming memo, acoustic guitarist, proud daddy of 5 and great listener (to my kids)