Last active
August 10, 2020 18:40
-
-
Save chatterjeesunit/af1314e0e29c0406013c7af49cfefa6e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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