Official Readme

uber-go/zap: Blazing fast, structured, leveled logging in Go.

  1. logger, _ := zap.NewProduction()
  2. defer logger.Sync() // flushes buffer, if any
  3. sugar := logger.Sugar()
  4. sugar.Infow("failed to fetch URL",
  5. // Structured context as loosely typed key-value pairs.
  6. "url", url,
  7. "attempt", 3,
  8. "backoff", time.Second,
  9. )
  10. sugar.Infof("Failed to fetch URL: %s", url)