Fix pkg.go.dev badge
Fork clog for personal use
Fix README example
go get go.spiff.io/clog
clog is a simple package for attaching a Zap logger to a context, along with functions for logging from the context-attached logger or associating new fields to the logger.
Generally speaking this is a bad use of the context package, but utility won out over passing both a context and a logger around all the time. In particular, this is useful for passing a request-scoped logger through different http.Handler implementations that otherwise do not support Zap.
This is a fork of https://github.com/Kochava/clog.
A few examples of basic usage follow.
// var l *zap.Logger
// Attach the logger, l, to a context:
ctx := clog.WithLogger(context.Background(), l)
// Attach fields to the logger:
ctx = clog.With(ctx, zap.Int("field", 1234))
// Log at info level:
clog.Info(ctx, "Log message")
clog is made available under the ISC license. A copy of it can be found in the
repository in the COPYING
file.