Skip to content

Instantly share code, notes, and snippets.

@chatterjeesunit
Last active August 10, 2020 18:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chatterjeesunit/af1314e0e29c0406013c7af49cfefa6e to your computer and use it in GitHub Desktop.
Save chatterjeesunit/af1314e0e29c0406013c7af49cfefa6e to your computer and use it in GitHub Desktop.
var logger *zap.Logger
func main() {
InitLogger()
defer logger.Sync()
SimpleHttpGet("www.google.com")
SimpleHttpGet("http://www.google.com")
}
func InitLogger() {
logger, _ = zap.NewProduction()
}
func SimpleHttpGet(url string) {
resp, err := http.Get(url)
if err != nil {
logger.Error(
"Error fetching url..",
zap.String("url", url),
zap.Error(err))
} else {
logger.Info("Success..",
zap.String("statusCode", resp.Status),
zap.String("url", url))
resp.Body.Close()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment