Skip to content

uber-go zap logger handy wrappers and tools.

License

Notifications You must be signed in to change notification settings

na4ma4/go-zaptool

Repository files navigation

go-zaptool

CI GoDoc GitHub issues GitHub forks GitHub stars GitHub license

uber-go/zap wrappers and tools.

Install

go get -u github.com/na4ma4/go-zaptool

Tools

LogLevels

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")

HTTP Logging Handler

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)

About

uber-go zap logger handy wrappers and tools.

Resources

License

Stars

Watchers

Forks

Packages

No packages published