Created
July 29, 2018 06:18
-
-
Save qbig/adb265dfc93b793fe4d934e6b61ec6e6 to your computer and use it in GitHub Desktop.
Uber Faster logger go.uber.org/zap
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
// slower but easier & loosely typed interface | |
sugar := zap.NewExample().Sugar() | |
defer sugar.Sync() | |
sugar.Infow("failed to fetch URL", | |
"url", "http://example.com", | |
"attempt", 3, | |
"backoff", time.Second, | |
) | |
sugar.Infof("failed to fetch URL: %s", "http://example.com") | |
// faster logging | |
logger := zap.NewExample() | |
defer logger.Sync() | |
logger.Info("failed to fetch URL", | |
zap.String("url", "http://example.com"), | |
zap.Int("attempt", 3), | |
zap.Duration("backoff", time.Second), | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment