All notable changes to this project will be documented in this file.
This project adheres to Semantic Versioning.
Enhancements:
WithLazy method for SugaredLogger.NewTestingWriter for customizing TestingWriter with more flexibility than NewLogger.Log, Logw, Logln methods for SugaredLogger.WithPanicHook option for testing panic logs.Thanks to @defval, @dimmo, @arxeiss, and @MKrupauskas for their contributions to this release.
Enhancements:
WithLazy method to Logger which lazily evaluates the structured context.Thanks to @hhk7734, @jquirke, and @cdvr1993 for their contributions to this release.
This release contains several improvements including performance, API additions, and two new experimental packages whose APIs are unstable and may change in the future.
Enhancements:
zap/exp/zapslog package for integration with slog.Name to Logger which returns the Logger's name if one is set.zap/exp/expfield package which contains helper methods Str and Strs for constructing String-like zap.Fields.Any.Thanks to @knight42, @dzakaammar, @bcspragu, and @rexywork for their contributions to this release.
Enhancements:
Level to both Logger and SugaredLogger that reports the current minimum enabled log level.SugaredLogger turns errors to zap.Error automatically.Thanks to @Abirdcfly, @craigpastro, @nnnkkk7, and @sashamelentyev for their contributions to this release.
Enhancements:
zapcore.LevelOf function to determine the level of a LevelEnabler or Core.zap.Stringers field constructor to log arrays of objects that implement String() string.Enhancements:
zap.Objects and zap.ObjectValues field constructors to log arrays of objects. With these two constructors, you don't need to implement zapcore.ArrayMarshaler for use with zap.Array if those objects implement zapcore.ObjectMarshaler.SugaredLogger.WithOptions to build a copy of an existing SugaredLogger with the provided options applied.*ln variants to SugaredLogger for each log level. These functions provide a string joining behavior similar to fmt.Println.zap.WithFatalHook option to control the behavior of the logger for Fatal-level log entries. This defaults to exiting the program.zap.Must function that you can use with NewProduction or NewDevelopment to panic if the system was unable to build the logger.Logger.Log method that allows specifying the log level for a statement dynamically.Thanks to @cardil, @craigpastro, @sashamelentyev, @shota3506, and @zhupeijun for their contributions to this release.
Enhancements:
zapcore.ParseLevel to parse a Level from a string.zap.ParseAtomicLevel to parse an AtomicLevel from a string.Bugfixes:
EncodeLevel is unset.Other changes:
AddCaller and AddStacktrace options are used together.Thanks to @aerosol and @Techassi for their contributions to this release.
Enhancements:
EncoderConfig.SkipLineEnding flag to disable adding newline characters between log statements.EncoderConfig.NewReflectedEncoder field to customize JSON encoding of reflected log fields.Bugfixes:
MarshalLogObject methods when the methods return.thereafter is zero.Other changes:
Thanks to @psrajat, @lruggieri, @sammyrnycreal for their contributions to this release.
Bugfixes:
Enhancements:
Thanks to @lancoLiu and @thockin for their contributions to this release.
Bugfixes:
zap.NewNop.Enhancements:
zapcore.BufferedWriteSyncer, a new WriteSyncer that buffers messages in-memory and flushes them periodically.zapio.Writer to use a Zap logger as an io.Writer.zap.WithClock option to control the source of time via the new zapcore.Clock interface.zap.SugaredLogger when arguments of *w methods don't match expectations.zaptest/observer.io.StringWriter and io.ByteWriter in Zap's buffer.Buffer.Thanks to @atrn0, @ernado, @heyanfu, @hnlq715, @zchee for their contributions to this release.
Bugfixes:
<nil> for nil error instead of a panic.Enhancements:
grpclog.LoggerV2 in zapgrpc.application/x-www-form-urlencoded content type.zap.Inline.zaptest/observer.Thanks to @ash2k, @FMLS, @jimmystewpot, @Oncilla, @tsoslow, @tylitianrui, @withshubh, and @wziww for their contributions to this release.
Bugfixes:
0666 and rely on the umask instead.<nil> for nil Stringer instead of a panic error log.Enhancements:
zapcore.TimeEncoderOfLayout to easily create time encoders for custom layouts.StackSkip for including truncated stacks as a field.Thanks to @SteelPhase, @tmshn, @lixingwang, @wyxloading, @moul, @segevfiner, @andy-retailnext and @jcorbin for their contributions to this release.
Bugfixes:
Time values out of UnixNano range.IncreaseLevel being reset after a call to With.Enhancements:
WithCaller option to supersede the AddCaller option. This allows disabling annotation of log entries with caller information if previously enabled with AddCaller.NewSampler constructor in favor of NewSamplerWithOptions which supports a SamplerHook option. This option adds support for monitoring sampling decisions through a hook.Thanks to @danielbprice for their contributions to this release.
Bugfixes:
go mod vendor no longer includes Zap's development-time dependencies.time.Time objects when using string-based time formats.Thanks to @YashishDua for their contributions to this release.
Enhancements:
Time.AppendFormat where possible.Thanks to @caibirdme for their contributions to this release.
Enhancements:
Intp, Stringp, and other similar *p field constructors to log pointers to primitives with support for nil values.Thanks to @jbizzle for their contributions to this release.
Enhancements:
Enhancements:
zapcore.OmitKey to omit keys in an EncoderConfig.RFC3339 and RFC3339Nano time encoders.Thanks to @juicemia, @uhthomas for their contributions to this release.
Bugfixes:
MapObjectEncoder.AppendByteString not adding value as a string.Enhancements:
zaptest.WrapOptions to wrap zap.Option for creating test loggers.Thanks to @iaroslav-ciupin, @lelenanam, @joa, @NWilson for their contributions to this release.
Bugfixes:
Enhancements:
Thanks to @nfarah86, @AlekSi, @JeanMertz, @philippgille, @etsangsplk, and @dimroc for their contributions to this release.
Enhancements:
*testing.TB.zapcore.Field to clean up GoDoc.Bugfixes:
go.uber.org/zap/buffer.Thanks to @DiSiqueira and @djui for their contributions to this release.
Bugfixes:
Enhancements:
NewStdLogAt, which extends NewStdLog by allowing the user to specify the level of the logged messages.Enhancements:
ContextMap method to observer logs for simpler field validation in tests.Enhancements:
go.uber.org/multierr.Bugfixes:
Thanks to @richard-tunein and @pavius for their contributions to this release.
This release fixes two bugs.
Bugfixes:
This release adds a few small features and is fully backward-compatible.
Enhancements:
LineEnding field to EncoderConfig, allowing users to override the Unix-style default.zap.AtomicLevel implement fmt.Stringer, which makes a variety of operations a bit simpler.This release adds an enhancement to zap's testing helpers as well as the ability to marshal an AtomicLevel. It is fully backward-compatible.
Enhancements:
SugaredLogger.AtomicLevel implement encoding.TextMarshaler.This release adds a gRPC compatibility wrapper. It is fully backward-compatible.
Enhancements:
zapgrpc package that wraps zap's Logger and implements grpclog.Logger.This release fixes two bugs and adds some enhancements to zap's testing helpers. It is fully backward-compatible.
Bugfixes:
Enhancements:
Thanks to @moitias for contributing to this release.
This is zap's first stable release. All exported APIs are now final, and no further breaking changes will be made in the 1.x release series. Anyone using a semver-aware dependency manager should now pin to ^1.
Breaking changes:
[]byte to string.Sync methods to zapcore.Core, zap.Logger, and zap.SugaredLogger.testutils package to zaptest, which is less likely to clash with other testing helpers.Bugfixes:
zapcore.NewCore, which allows zap to work with concurrency-safe WriteSyncer implementations.fsync standard out on Linux systems.Enhancements:
Config.CombineWriteSyncers, a convenience function to tee multiple WriteSyncers and lock the result.zaptest/observer. This makes it easier for particularly punctilious users to unit test their application's logging.Thanks to @suyash, @htrendev, @flisky, @Ulexus, and @skipor for their contributions to this release.
This is the third release candidate for zap's stable release. There are no breaking changes.
Bugfixes:
zap.Any are now correctly treated as binary blobs rather than []uint8.Enhancements:
log.Logger instance.Thanks to @ansel1 and @suyash for their contributions to this release.
This is the second release candidate for zap's stable release. It includes two breaking changes.
Breaking changes:
#316: Zap's global loggers are now fully concurrency-safe (previously, users had to ensure that ReplaceGlobals was called before the loggers were in use). However, they must now be accessed via the L() and S() functions. Users can update their projects with
gofmt -r "zap.L -> zap.L()" -w . gofmt -r "zap.S -> zap.S()" -w .
#309 and #317: RC1 was mistakenly shipped with invalid JSON and YAML struct tags on all config structs. This release fixes the tags and adds static analysis to prevent similar bugs in the future.
Bugfixes:
log output now correctly reports the logger's caller.Enhancements:
github.com/pkg/errors.New(nil) continues to return a no-op logger, NewNop() is now preferred. Users can update their projects with gofmt -r 'zap.New(nil) -> zap.NewNop()' -w ..github.com/uber-go/zap now returns a more informative error.Thanks to @skipor and @chapsuk for their contributions to this release.
This is the first release candidate for zap's stable release. There are multiple breaking changes and improvements from the pre-release version. Most notably:
zap package. Code relevant largely to extension authors is now in the zapcore package.zapcore.Core type makes it easy for third-party packages to use zap's internals but provide a different user-facing API.Logger is now a concrete type instead of an interface.L and S are included.This is a minor version, tagged to allow users to pin to the pre-1.0 APIs and upgrade at their leisure. Since this is the first tagged release, there are no backward compatibility concerns and all functionality is new.
Early zap adopters should pin to the 0.1.x minor version until they're ready to upgrade to the upcoming stable release.