Package Usage: go: go.uber.org/zap
Package zap provides fast, structured, leveled logging.
For applications that log in the hot path, reflection-based serialization
and string formatting are prohibitively expensive - they're CPU-intensive
and make many small allocations. Put differently, using json.Marshal and
fmt.Fprintf to log tons of interface{} makes your application slow.
Zap takes a different approach. It includes a reflection-free,
zero-allocation JSON encoder, and the base Logger strives to avoid
serialization overhead and allocations wherever possible. By building the
high-level SugaredLogger on that foundation, zap lets users choose when
they need to count every allocation and when they'd prefer a more familiar,
loosely typed API.
In contexts where performance is nice, but not critical, use the
SugaredLogger. It's 4-10x faster than other structured logging packages and
supports both structured and printf-style logging. Like log15 and go-kit,
the SugaredLogger's structured logging APIs are loosely typed and accept a
variadic number of key-value pairs. (For more advanced use cases, they also
accept strongly typed fields - see the SugaredLogger.With documentation for
details.)
By default, loggers are unbuffered. However, since zap's low-level APIs
allow buffering, calling Sync before letting your process exit is a good
habit.
In the rare contexts where every microsecond and every allocation matter,
use the Logger. It's even faster than the SugaredLogger and allocates far
less, but it only supports strongly-typed, structured logging.
Choosing between the Logger and SugaredLogger doesn't need to be an
application-wide decision: converting between the two is simple and
inexpensive.
The simplest way to build a Logger is to use zap's opinionated presets:
NewExample, NewProduction, and NewDevelopment. These presets build a logger
with a single function call:
Presets are fine for small projects, but larger projects and organizations
naturally require a bit more customization. For most users, zap's Config
struct strikes the right balance between flexibility and convenience. See
the package-level BasicConfiguration example for sample code.
More unusual configurations (splitting output between files, sending logs
to a message queue, etc.) are possible, but require direct use of
go.uber.org/zap/zapcore. See the package-level AdvancedConfiguration
example for sample code.
The zap package itself is a relatively thin wrapper around the interfaces
in go.uber.org/zap/zapcore. Extending zap to support a new encoding (e.g.,
BSON), a new log sink (e.g., Kafka), or something more exotic (perhaps an
exception aggregation service, like Sentry or Rollbar) typically requires
implementing the zapcore.Encoder, zapcore.WriteSyncer, or zapcore.Core
interfaces. See the zapcore documentation for details.
Similarly, package authors can use the high-performance Encoder and Core
implementations in the zapcore package to build their own loggers.
An FAQ covering everything from installation errors to design decisions is
available at https://github.com/uber-go/zap/blob/master/FAQ.md.
38 versions
Latest release: about 1 year ago
35,840 dependent packages
View more package details: https://packages.ecosystem.code.gouv.fr/registries/proxy.golang.org/packages/go.uber.org/zap
Dependent Repos 18
swh/infra/ci-cd/3rdparty/cert-manager-webhook-gandi
Last synced: 7 months ago - Pushed: 11 months ago
cea-hpc/sshproxy
Proxy SSH connections on a gatewaySize: 9.34 MB - Last synced: 1 day ago - Pushed: 18 days ago

radiofrance/gitlab-ci-pipelines-exporter
Rewrite of https://github.com/mvisonneau/gitlab-ci-pipelines-exporter without Gitlab API requestsSize: 546 KB - Last synced: about 13 hours ago - Pushed: about 13 hours ago

betagouv/vouch-proxy Fork of vouch/vouch-proxy
an SSO and OAuth / OIDC login solution for Nginx using the auth_request moduleSize: 5.68 MB - Last synced: about 12 hours ago - Pushed: over 1 year ago

cea-hpc/fabricmon Fork of dswarbrick/fabricmon
InfiniBand fabric monitoring daemon written in GoSize: 404 KB - Last synced: 1 day ago - Pushed: 6 months ago

radiofrance/ipahealthcheck_exporter Fork of camptocamp/ipahealthcheck_exporter
Prometheus exporter for exposing ipa-healthcheck tool checks as metricsSize: 60.5 KB - Last synced: about 13 hours ago - Pushed: almost 4 years ago

tchapgouv/lk-jwt-service Fork of element-hq/lk-jwt-service
Minimal service to provide LiveKit JWTs using Matrix OpenID ConnectSize: 68.4 KB - Last synced: about 15 hours ago - Pushed: 7 months ago

signaux-faibles/wekan-alerter
wekan-alerterSize: 44.9 KB - Last synced: about 18 hours ago - Pushed: over 2 years ago

signaux-faibles/goup
Serveur minimaliste pour téléverser des fichiers avec une gestion de droitsSize: 63.1 MB - Last synced: about 18 hours ago - Pushed: over 2 years ago


radiofrance/helm-chart-sonarqube Fork of SonarSource/helm-chart-sonarqube
Size: 2.99 MB - Last synced: 7 months ago - Pushed: 9 months ago

web-et-numerique/factory/llle_project/cozy-stack
Fork of cozy-stack https://github.com/cozy/cozy-stackLast synced: 7 months ago
