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.
[#1378]: https://github.com/uber-go/zap/pull/1378 [#1399]: https://github.com/uber-go/zap/pull/1399 [#1406]: https://github.com/uber-go/zap/pull/1406 [#1416]: https://github.com/uber-go/zap/pull/1416
Enhancements:
WithLazy method to Logger which lazily evaluates the structuredcontext.
Thanks to @hhk7734, @jquirke, and @cdvr1993 for their contributions to this release.
[#1297]: https://github.com/uber-go/zap/pull/1297 [#1319]: https://github.com/uber-go/zap/pull/1319 [#1350]: https://github.com/uber-go/zap/pull/1350
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 methodsStr and Strs for constructing String-like zap.Fields.
Any.Thanks to @knight42, @dzakaammar, @bcspragu, and @rexywork for their contributions to this release.
[#1246]: https://github.com/uber-go/zap/pull/1246 [#1273]: https://github.com/uber-go/zap/pull/1273 [#1281]: https://github.com/uber-go/zap/pull/1281 [#1310]: https://github.com/uber-go/zap/pull/1310
Enhancements:
Level to both Logger and SugaredLogger that reports thecurrent minimum enabled log level.
SugaredLogger turns errors to zap.Error automatically.Thanks to @Abirdcfly, @craigpastro, @nnnkkk7, and @sashamelentyev for their contributions to this release.
[#1148]: https://github.coml/uber-go/zap/pull/1148 [#1185]: https://github.coml/uber-go/zap/pull/1185
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.
[#1147]: https://github.com/uber-go/zap/pull/1147 [#1155]: https://github.com/uber-go/zap/pull/1155
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 fora statement dynamically.
Thanks to @cardil, @craigpastro, @sashamelentyev, @shota3506, and @zhupeijun for their contributions to this release.
[#1071]: https://github.com/uber-go/zap/pull/1071 [#1079]: https://github.com/uber-go/zap/pull/1079 [#1080]: https://github.com/uber-go/zap/pull/1080 [#1088]: https://github.com/uber-go/zap/pull/1088 [#1108]: https://github.com/uber-go/zap/pull/1108 [#1118]: https://github.com/uber-go/zap/pull/1118
Enhancements:
zapcore.ParseLevel to parse a Level from a string.zap.ParseAtomicLevel to parse an AtomicLevel from astring.
Bugfixes:
EncodeLevel is unset.Other changes:
AddCaller and AddStacktrace options are used together.
[#1047]: https://github.com/uber-go/zap/pull/1047 [#1048]: https://github.com/uber-go/zap/pull/1048 [#1052]: https://github.com/uber-go/zap/pull/1052 [#1058]: https://github.com/uber-go/zap/pull/1058
Thanks to @aerosol and @Techassi for their contributions to this release.
Enhancements:
EncoderConfig.SkipLineEnding flag to disable adding newlinecharacters between log statements.
EncoderConfig.NewReflectedEncoder field to customize JSONencoding of reflected log fields.
Bugfixes:
MarshalLogObjectmethods when the methods return.
thereafter is zero.Other changes:
[#554]: https://github.com/uber-go/zap/pull/554 [#989]: https://github.com/uber-go/zap/pull/989 [#1011]: https://github.com/uber-go/zap/pull/1011 [#1017]: https://github.com/uber-go/zap/pull/1017 [#1028]: https://github.com/uber-go/zap/pull/1028 [#1033]: https://github.com/uber-go/zap/pull/1033 [#1039]: https://github.com/uber-go/zap/pull/1039
Thanks to @psrajat, @lruggieri, @sammyrnycreal for their contributions to this release.
Bugfixes:
[#1001]: https://github.com/uber-go/zap/pull/1001 [#1003]: https://github.com/uber-go/zap/pull/1003
Enhancements:
better.
[#975]: https://github.com/uber-go/zap/pull/975 [#984]: https://github.com/uber-go/zap/pull/984
Thanks to @lancoLiu and @thockin for their contributions to this release.
Bugfixes:
zap.NewNop.[#974]: https://github.com/uber-go/zap/pull/974
Enhancements:
zapcore.BufferedWriteSyncer, a new WriteSyncer that buffersmessages 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 *wmethods 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.
[#691]: https://github.com/uber-go/zap/pull/691 [#897]: https://github.com/uber-go/zap/pull/897 [#943]: https://github.com/uber-go/zap/pull/943 [#949]: https://github.com/uber-go/zap/pull/949 [#961]: https://github.com/uber-go/zap/pull/961 [#971]: https://github.com/uber-go/zap/pull/971
Bugfixes:
<nil> for nil error instead of a panic.vulnerabilities in dependencies.
Enhancements:
size from 96 to 80 bytes.
grpclog.LoggerV2 in zapgrpc. with the 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.
[#865]: https://github.com/uber-go/zap/pull/865 [#867]: https://github.com/uber-go/zap/pull/867 [#881]: https://github.com/uber-go/zap/pull/881 [#903]: https://github.com/uber-go/zap/pull/903 [#912]: https://github.com/uber-go/zap/pull/912 [#913]: https://github.com/uber-go/zap/pull/913 [#928]: https://github.com/uber-go/zap/pull/928 [#931]: https://github.com/uber-go/zap/pull/931 [#936]: https://github.com/uber-go/zap/pull/936
Bugfixes:
without specifying a time or duration encoder.
0666 and rely on the umask instead.<nil> for nil Stringer instead of a panic error log.Enhancements:
zapcore.TimeEncoderOfLayout to easily create time encodersfor 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.
[#629]: https://github.com/uber-go/zap/pull/629 [#697]: https://github.com/uber-go/zap/pull/697 [#828]: https://github.com/uber-go/zap/pull/828 [#835]: https://github.com/uber-go/zap/pull/835 [#843]: https://github.com/uber-go/zap/pull/843 [#844]: https://github.com/uber-go/zap/pull/844 [#852]: https://github.com/uber-go/zap/pull/852 [#854]: https://github.com/uber-go/zap/pull/854 [#861]: https://github.com/uber-go/zap/pull/861 [#862]: https://github.com/uber-go/zap/pull/862
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.
[#804]: https://github.com/uber-go/zap/pull/804 [#812]: https://github.com/uber-go/zap/pull/812 [#806]: https://github.com/uber-go/zap/pull/806 [#813]: https://github.com/uber-go/zap/pull/813
Bugfixes:
go mod vendor no longer includes Zap'sdevelopment-time dependencies.
be generated for arrays of time.Time objects when using string-based time
formats.
Thanks to @YashishDua for their contributions to this release.
[#791]: https://github.com/uber-go/zap/pull/791 [#795]: https://github.com/uber-go/zap/pull/795 [#799]: https://github.com/uber-go/zap/pull/799
Enhancements:
Time.AppendFormat where possible.Thanks to @caibirdme for their contributions to this release.
[#771]: https://github.com/uber-go/zap/pull/771 [#773]: https://github.com/uber-go/zap/pull/773 [#775]: https://github.com/uber-go/zap/pull/775 [#786]: https://github.com/uber-go/zap/pull/786
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.
[#758]: https://github.com/uber-go/zap/pull/758
Enhancements:
[#751]: https://github.com/uber-go/zap/pull/751
Enhancements:
zapcore.OmitKey to omit keys in an EncoderConfig.RFC3339 and RFC3339Nano time encoders.Thanks to @juicemia, @uhthomas for their contributions to this release.
[#725]: https://github.com/uber-go/zap/pull/725 [#736]: https://github.com/uber-go/zap/pull/736
Bugfixes:
MapObjectEncoder.AppendByteString not adding value as astring.
Enhancements:
zaptest.WrapOptions to wrap zap.Option for creating testloggers.
reflect-based encoder.
Thanks to @iaroslav-ciupin, @lelenanam, @joa, @NWilson for their contributions to this release.
[#657]: https://github.com/uber-go/zap/pull/657 [#706]: https://github.com/uber-go/zap/pull/706 [#610]: https://github.com/uber-go/zap/pull/610 [#675]: https://github.com/uber-go/zap/pull/675 [#704]: https://github.com/uber-go/zap/pull/704
Bugfixes:
[#614]: https://github.com/uber-go/zap/pull/614
Enhancements:
Thanks to @nfarah86, @AlekSi, @JeanMertz, @philippgille, @etsangsplk, and @dimroc for their contributions to this release.
[#602]: https://github.com/uber-go/zap/pull/602 [#572]: https://github.com/uber-go/zap/pull/572 [#606]: https://github.com/uber-go/zap/pull/606
Enhancements:
library's logger.
*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.
[#508]: https://github.com/uber-go/zap/pull/508 [#518]: https://github.com/uber-go/zap/pull/518 [#577]: https://github.com/uber-go/zap/pull/577 [#574]: https://github.com/uber-go/zap/pull/574
Bugfixes:
[#504]: https://github.com/uber-go/zap/pull/504
Enhancements:
NewStdLogAt, which extends NewStdLog by allowing the userto specify the level of the logged messages.
[#487]: https://github.com/uber-go/zap/pull/487
Enhancements:
ContextMap method to observer logs for simplerfield validation in tests.
[#490]: https://github.com/uber-go/zap/pull/490 [#491]: https://github.com/uber-go/zap/pull/491
Enhancements:
go.uber.org/multierr.Bugfixes:
Thanks to @richard-tunein and @pavius for their contributions to this release.
[#477]: https://github.com/uber-go/zap/pull/477 [#465]: https://github.com/uber-go/zap/pull/465 [#460]: https://github.com/uber-go/zap/pull/460 [#470]: https://github.com/uber-go/zap/pull/470
This release fixes two bugs.
Bugfixes:
[#435]: https://github.com/uber-go/zap/pull/435 [#444]: https://github.com/uber-go/zap/pull/444
This release adds a few small features and is fully backward-compatible.
Enhancements:
LineEnding field to EncoderConfig, allowing users tooverride the Unix-style default.
zap.AtomicLevel implement fmt.Stringer, which makes avariety of operations a bit simpler.
[#424]: https://github.com/uber-go/zap/pull/424 [#425]: https://github.com/uber-go/zap/pull/425 [#431]: https://github.com/uber-go/zap/pull/431
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:
particularly useful when testing the SugaredLogger.
AtomicLevel implement encoding.TextMarshaler.[#415]: https://github.com/uber-go/zap/pull/415 [#416]: https://github.com/uber-go/zap/pull/416
This release adds a gRPC compatibility wrapper. It is fully backward-compatible.
Enhancements:
zapgrpc package that wraps zap's Logger and implements grpclog.Logger.
[#402]: https://github.com/uber-go/zap/pull/402
This release fixes two bugs and adds some enhancements to zap's testing helpers. It is fully backward-compatible.
Bugfixes:
zap's configuration struct.
Enhancements:
Thanks to @moitias for contributing to this release.
[#385]: https://github.com/uber-go/zap/pull/385 [#396]: https://github.com/uber-go/zap/pull/396 [#386]: https://github.com/uber-go/zap/pull/386
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:
casting from []byte to string.
Sync methods to zapcore.Core, zap.Logger, and zap.SugaredLogger.
testutils package to zaptest, which is less likely toclash with other testing helpers.
Bugfixes:
for tab-separated console output.
zapcore.NewCore, which allows zap to work with concurrency-safe WriteSyncer implementations.
fsync standard out on Linuxsystems.
interoperability wrappers.
Enhancements:
built-in Config.
levels, and durations).
removes the last performance advantage that zap's encoders have over plugins.
CombineWriteSyncers, a convenience function to tee multiple WriteSyncers and lock the result.
Go 1.9).
zaptest/observer. This makes iteasier 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.
[#366]: https://github.com/uber-go/zap/pull/366 [#364]: https://github.com/uber-go/zap/pull/364 [#371]: https://github.com/uber-go/zap/pull/371 [#362]: https://github.com/uber-go/zap/pull/362 [#369]: https://github.com/uber-go/zap/pull/369 [#347]: https://github.com/uber-go/zap/pull/347 [#373]: https://github.com/uber-go/zap/pull/373 [#348]: https://github.com/uber-go/zap/pull/348 [#327]: https://github.com/uber-go/zap/pull/327 [#376]: https://github.com/uber-go/zap/pull/376 [#346]: https://github.com/uber-go/zap/pull/346 [#365]: https://github.com/uber-go/zap/pull/365 [#372]: https://github.com/uber-go/zap/pull/372
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:
package-global logging functions, users can now construct a zap-backed
log.Logger instance.
machinery are now omitted from stacktraces.
Thanks to @ansel1 and @suyash for their contributions to this release.
[#339]: https://github.com/uber-go/zap/pull/339 [#307]: https://github.com/uber-go/zap/pull/307 [#353]: https://github.com/uber-go/zap/pull/353 [#311]: https://github.com/uber-go/zap/pull/311
This is the second release candidate for zap's stable release. It includes two breaking changes.
Breaking changes:
(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 .
`
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 nowcorrectly reports the logger's caller.
Enhancements:
errors like those produced by github.com/pkg/errors.
New(nil) continues to return a no-op logger, NewNop() isnow preferred. Users can update their projects with `gofmt -r 'zap.New(nil) -> zap.NewNop()' -w .`.
github.com/uber-go/zap now returns amore informative error.
Thanks to @skipor and @chapsuk for their contributions to this release.
[#316]: https://github.com/uber-go/zap/pull/316 [#309]: https://github.com/uber-go/zap/pull/309 [#317]: https://github.com/uber-go/zap/pull/317 [#321]: https://github.com/uber-go/zap/pull/321 [#325]: https://github.com/uber-go/zap/pull/325 [#333]: https://github.com/uber-go/zap/pull/333 [#326]: https://github.com/uber-go/zap/pull/326 [#300]: https://github.com/uber-go/zap/pull/300
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:
need to update their code.
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'sinternals but provide a different user-facing API.
Logger is now a concrete type instead of an interface.L and S are included.as configuration instead of code.
timer heap.
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.