Skip to content

Instantly share code, notes, and snippets.

@qbig
Created July 29, 2018 06:18
Show Gist options
  • Save qbig/adb265dfc93b793fe4d934e6b61ec6e6 to your computer and use it in GitHub Desktop.
Save qbig/adb265dfc93b793fe4d934e6b61ec6e6 to your computer and use it in GitHub Desktop.
Uber Faster logger go.uber.org/zap
// 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