Last active
August 10, 2020 18:40
-
-
Save chatterjeesunit/6929fc7ea2fbd2b803ab768071977f22 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 sugarLogger *zap.SugaredLogger | |
func main() { | |
InitLogger() | |
defer sugarLogger.Sync() | |
SimpleHttpGet("www.google.com") | |
SimpleHttpGet("http://www.google.com") | |
} | |
func InitLogger() { | |
logger, _ := zap.NewProduction() | |
sugarLogger = logger.Sugar() | |
} | |
func SimpleHttpGet(url string) { | |
sugarLogger.Debugf("Trying to hit GET request for %s", url) | |
resp, err := http.Get(url) | |
if err != nil { | |
sugarLogger.Errorf("Error fetching URL %s : Error = %s", url, err) | |
} else { | |
sugarLogger.Infof("Success! statusCode = %s for URL %s", resp.Status, url) | |
resp.Body.Close() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment