Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: uber-go/zap
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.17.0
Choose a base ref
...
head repository: uber-go/zap
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.19.1
Choose a head ref

Commits on Jan 8, 2021

  1. Add WithClock Option (#897)

    Add WithClock option to control the source of time for logged entries.
    
    Fixes #694
    
    Co-authored-by: Abhinav Gupta <abg@uber.com>
    ernado and abhinav authored Jan 8, 2021
    Copy the full SHA
    f8ef926 View commit details

Commits on Feb 2, 2021

  1. http: support additional content type (#903)

    Support `application/x-www-form-urlencoded` as an additional content
    type for `AtomicLevel.ServeHTTP`.
    
    This is the default content type for `curl -X POST`.
    
    With this change, interacting with the HTTP endpoint is a bit more
    user friendly:
    
    ```
    curl -X PUT localhost:8080/log/level -d level=debug
    ```
    
    Additionally, the unit tests for the HTTP handler are transformed to
    a table driven approach.
    
    fixes #902
    
    Co-authored-by: Abhinav Gupta <abg@uber.com>
    oncilla and abhinav authored Feb 2, 2021
    Copy the full SHA
    b274f65 View commit details

Commits on Feb 3, 2021

  1. Copy the full SHA
    89d9466 View commit details

Commits on Feb 8, 2021

  1. Optimize Sugar logger for calls with a single string arg (#913)

    Currently, the Sugar logger uses fmt.Sprint in all cases when the
    template is empty. However, this call is unnecessary if there's
    a single string type argument, as we can use it directly.
    
    With this optimization, we reduce the cost and avoid an unnecessary
    alloc:
    ```
    > benchcmp pre post
    benchmark                         old ns/op     new ns/op     delta
    BenchmarkSugarSingleStrArg-10     636           570           -10.38%
    
    benchmark                         old allocs     new allocs     delta
    BenchmarkSugarSingleStrArg-10     1              0              -100.00%
    ```
    prashantv authored Feb 8, 2021
    Copy the full SHA
    4f6f7e9 View commit details

Commits on Feb 9, 2021

  1. Copy the full SHA
    ab0cbad View commit details

Commits on Feb 12, 2021

  1. tools: Move to submodule (#914)

    This moves development tool dependencies to a subdirectory so that
    these are not added as dependencies of zap.
    markusthoemmes authored Feb 12, 2021
    Copy the full SHA
    aecb309 View commit details
  2. Add support for grpclog.LoggerV2 (#881)

    gRPC has an updated [logger interface][1] that the v1 API has been
    deprecated in favor of.
    
    [1]: https://pkg.go.dev/google.golang.org/grpc/grpclog#LoggerV2
    
    This adds support for it to the existing gRPC adapter in Zap.
    
    Fixes #534 
    Closes #538
    
    Co-authored-by: Prashant Varanasi <github@prashantv.com>
    Co-authored-by: Abhinav Gupta <abg@uber.com>
    3 people authored Feb 12, 2021
    Copy the full SHA
    89e3820 View commit details

Commits on Mar 23, 2021

  1. Support multi-field encoding using zap.Inline (#912)

    Fixes #876
    
    Currently, a `zap.Field` can only represent a single key-value. Add
    `zap.Inline` to allow adding multiple fields to the current
    namespace from a type implementing `zap.ObjectMarshaler`.
    
    This also solves a more general problem: a single `zap.Field` can now
    be used to add multiple key/value pairs.
    prashantv authored Mar 23, 2021
    Copy the full SHA
    ca7ddee View commit details
  2. Add FilterFieldKey to zaptest/observer (#928)

    Adds functionality to filter zap.Field by key. This makes testing for
    field existence regardless of value more convenient.
    
    resolves #816
    r-hang authored Mar 23, 2021
    Copy the full SHA
    bfa147a View commit details

Commits on Mar 29, 2021

  1. Update dependencies to fix vulnerabilities (#931)

    - go.uber.org/atomic@1.6.0
    - go.uber.org/multierr@1.5.0.
    
    Removes a lot of no longer needed dependencies and fixes vulnerabilities including the following:
    
    - golang.org/x/crypto (CVE-2020-9283)
    - golang.org/x/text (CVE-2020-14040)
    tsoslow authored Mar 29, 2021
    Copy the full SHA
    c23abee View commit details

Commits on Apr 20, 2021

  1. zapcore: Cleanup copy in NewMultiWriteSyncer (#934)

    The copy was originally in place due to golang/go#7809
    
    Since that issue was fixed in Go 1.3 a few years ago, it seems safe to
    drop the copy.
    prashantv authored Apr 20, 2021
    Copy the full SHA
    7b21229 View commit details

Commits on May 17, 2021

  1. Switch from Travis to GitHub Actions (#940)

    We're deprecating use of Travis for our OSS projects, so switch to
    GitHub Actions for it.
    
    Unfortunately, this required dropping tests we had against ppc64le
    because [GitHub Workflows doesn't support it][1].
    
      [1]: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#github-hosted-runners
    shirchen authored May 17, 2021
    Copy the full SHA
    d9a4dcc View commit details

Commits on May 18, 2021

  1. Update dependencies to fix vulnerabilities in (#936)

    - gopkg.in/yaml.v2 v2.2.2 -> v.2.2.8 CVE-2019-11254
    jimmystewpot authored May 18, 2021
    Copy the full SHA
    8b883c6 View commit details
  2. FAQ: Add zapfilter (#939)

    This utility allows creating a logger with "advanced" filters like in the following example.
    It is particularly convenient to use with a CLI flag package or using environment variables.
    
    	core := zap.NewExample().Core()
    	// *=myns             => any level, myns namespace
        // info,warn:myns.*   => info or warn level, any namespace matching myns.*
    	// error=*            => everything with error level
    	logger := zap.New(zapfilter.NewFilteringCore(core, zapfilter.MustParseRules("*:myns info,warn:myns.* error:*")))
    	defer logger.Sync()
    
    	logger.Debug("top debug")                                 // no match
    	logger.Named("myns").Debug("myns debug")                  // matches *:myns
    	logger.Named("bar").Debug("bar debug")                    // no match
    	logger.Named("myns").Named("foo").Debug("myns.foo debug") // no match
    
    	logger.Info("top info")                                 // no match
    	logger.Named("myns").Info("myns info")                  // matches *:myns
    	logger.Named("bar").Info("bar info")                    // no match
    	logger.Named("myns").Named("foo").Info("myns.foo info") // matches info,warn:myns.*
    
    	logger.Warn("top warn")                                 // no match
    	logger.Named("myns").Warn("myns warn")                  // matches *:myns
    	logger.Named("bar").Warn("bar warn")                    // no match
    	logger.Named("myns").Named("foo").Warn("myns.foo warn") // matches info,warn:myns.*
    
    	logger.Error("top error")                                 // matches error:*
    	logger.Named("myns").Error("myns error")                  // matches *:myns and error:*
    	logger.Named("bar").Error("bar error")                    // matches error:*
    	logger.Named("myns").Named("foo").Error("myns.foo error") // matches error:*
    
    	// Output:
    	// {"level":"debug","logger":"myns","msg":"myns debug"}
    	// {"level":"info","logger":"myns","msg":"myns info"}
    	// {"level":"info","logger":"myns.foo","msg":"myns.foo info"}
    	// {"level":"warn","logger":"myns","msg":"myns warn"}
    	// {"level":"warn","logger":"myns.foo","msg":"myns.foo warn"}
    	// {"level":"error","msg":"top error"}
    	// {"level":"error","logger":"myns","msg":"myns error"}
    	// {"level":"error","logger":"bar","msg":"bar error"}
    	// {"level":"error","logger":"myns.foo","msg":"myns.foo error"}
    moul authored May 18, 2021
    Copy the full SHA
    f73286f View commit details
  3. internal/readme: Simplify if condition (#945)

    Check for "both true" or "both false" is easily implemented as `x == y`.
    tylitianrui authored May 18, 2021
    Copy the full SHA
    debd2f1 View commit details
  4. go mod tidy (#947)

    A recent change to dependencies neglected to run `go mod tidy`.
    abhinav authored May 18, 2021
    Copy the full SHA
    3748251 View commit details

Commits on May 25, 2021

  1. clock: Add Ticker support (#948)

    In #897, we added a Clock interface to allow control over the source of
    time for operations that require accessing the current time. In #782,
    we discovered that this interface also needs the ability to construct
    tickers so that we can use it for the buffered writer.
    
    This change adds NewTicker to the Clock interface for Zap and moves it
    to the zapcore package as it will be needed for #782.
    
    Note that since we have not yet tagged a release of Zap with #897, this
    is not a breaking change.
    
    Co-authored-by: Minho Park <minho.park@uber.com>
    Co-authored-by: Abhinav Gupta <abg@uber.com>
    3 people authored May 25, 2021
    Copy the full SHA
    dedcdad View commit details
  2. clock: Move to zapcore (#950)

    We don't need to export the Clock interface from the top-level Zap
    package. This is a low-level API so we can keep it in zapcore only.
    abhinav authored May 25, 2021
    Copy the full SHA
    7699673 View commit details
  3. lint: Check that 'go mod tidy' was run (#951)

    In #948, we noticed that some `go.sum` files were outdated. To avoid
    this in the future, add a `lint` check that verifies that `go mod tidy`
    does not cause any changes.
    
    This will fail with a dirty working tree as well, but in CI, we don't
    expect that.
    abhinav authored May 25, 2021
    Copy the full SHA
    fec3dad View commit details
  4. Integrate FOSSA (#953)

    Add a FOSSA check to the build steps.
    
    Resolves: GO-468
    manjari25 authored May 25, 2021
    Copy the full SHA
    3c7c771 View commit details
  5. zapcore/FieldType: Don't change enum values (#955)

    Although the values of the FieldType enums aren't part of the Zap
    contract, changing existing values is still a risky change.
    
    [apidiff] considers this a brekaing change.
    
    ```
    Incompatible changes:
    - BinaryType: value changed from 3 to 4
    - BoolType: value changed from 4 to 5
    - ByteStringType: value changed from 5 to 6
    - Complex128Type: value changed from 6 to 7
    - Complex64Type: value changed from 7 to 8
    - DurationType: value changed from 8 to 9
    - ErrorType: value changed from 26 to 27
    - Float32Type: value changed from 10 to 11
    - Float64Type: value changed from 9 to 10
    - Int16Type: value changed from 13 to 14
    - Int32Type: value changed from 12 to 13
    - Int64Type: value changed from 11 to 12
    - Int8Type: value changed from 14 to 15
    - NamespaceType: value changed from 24 to 25
    - ReflectType: value changed from 23 to 24
    - SkipType: value changed from 27 to 28
    - StringType: value changed from 15 to 16
    - StringerType: value changed from 25 to 26
    - TimeFullType: value changed from 17 to 18
    - TimeType: value changed from 16 to 17
    - Uint16Type: value changed from 20 to 21
    - Uint32Type: value changed from 19 to 20
    - Uint64Type: value changed from 18 to 19
    - Uint8Type: value changed from 21 to 22
    - UintptrType: value changed from 22 to 23
    ```
    
      [apidiff]: https://github.com/golang/exp/blob/master/apidiff/README.md
    
    Again, although maintianing these values is not part of the Zap
    contract, in the interest of erring on the side of safety, I'm moving
    the new FieldType (added in #912) to the bottom to avoid changing the
    values of the other items.
    abhinav authored May 25, 2021
    Copy the full SHA
    56304dc View commit details
  6. fossa: Run separately, only on push (#957)

    Currently, the FOSSA analysis is set to run as part of CI. Minus the
    fact that it's not really part of the build, its reliance on a secret
    means that it won't run for any pull requests made from external forks.
    
    Resolve this by running the FOSSA analysis only when we push to a
    branch of the Zap repository.
    abhinav authored May 25, 2021
    Copy the full SHA
    cfe34dc View commit details
  7. Merge v1.17.0 release into master

    Release v1.17.0 omitted some changes that are present on master. Merge
    the release into master so that we can work off of that.
    abhinav committed May 25, 2021
    Copy the full SHA
    4950e39 View commit details

Commits on Jun 7, 2021

  1. SugaredLogger/sweetenFields: Don't panic (#949)

    SugaredLogger should not cause panics in user code.
    
    For keys without matching values or non-string keys, instead of
    panicking, log an error and move on.
    
    Resolves #896
    atrn0 authored Jun 7, 2021
    Copy the full SHA
    084fb2a View commit details

Commits on Jun 8, 2021

  1. zaptest/ObservedLogs: Expose more filters (#943)

    Currently consumers can call `(*ObservedLogs).All` and proceed to filter
    using `[]LoggedEntry` directly, but the result is then incompatible with
    existing methods such as `FilterMessage` because there is now way to
    re-construct an `*ObservedLogs` object.
    
    Add ObservedLogs.Filter and ObservedLogs.FilterLevelExact to allow
    filtering by arbitrary functions, or by exact level matches.
    jkanywhere authored Jun 8, 2021
    Copy the full SHA
    c05967d View commit details
  2. zapcore: Add Buffered Writer (#961)

    Add a BufferedWriteSyncer that buffers writes in memory before flushing
    them to the underlying WriteSyncer at some interval or when a
    configured amount of data has been buffered -- whichever comes first.
    
    The bulk of this change was authored by hnlq715 and Moises Vega.
    Prashant and I contributed minor fixes.
    
    Co-authored-by: hnlq715 <hnlq.sysu@gmail.com>
    Co-authored-by: Prashant Varanasi <prashant@uber.com>
    Co-authored-by: Moises Vega <moises@uber.com>
    4 people authored Jun 8, 2021
    Copy the full SHA
    aa3e73e View commit details

Commits on Jun 16, 2021

  1. fix typo (#967)

    heyanfu authored Jun 16, 2021
    Copy the full SHA
    0c42722 View commit details

Commits on Jun 24, 2021

  1. Copy the full SHA
    fb71758 View commit details
  2. Add Buffer.WriteByte and WriteString methods (#691)

    These methods are equivalent to `AppendByte` and `AppendString`, but
    their signatures are compatible with
    [bytes.Buffer](https://godoc.org/bytes#Buffer) and
    [bufio.Writer](https://godoc.org/bufio#Writer).
    
    This allows to use `Buffer` where `bytes.Buffer` was expected without
    extra cost of wrapping. One example is msgpack library which
    expects `Writer` to implement `WriteByte` and `WriteString`, otherwise
    it is wrapped which incurs extra allocation:
    https://github.com/vmihailenco/msgpack/blob/master/encode.go#L63-L67
    smira authored Jun 24, 2021
    Copy the full SHA
    5afb307 View commit details

Commits on Jun 25, 2021

  1. Add zapio.Writer (#971)

    This adds a new zapio package that provides a `Writer`. The writer
    implements `io.WriteCloser` and `zapcore.WriteSyncer`.
    
    It works by splitting the input on newlines, flushing to the logger as
    new lines are encountered, and buffering input otherwise.
    
    So for example, if write "foobar\n" is split across multiple Write calls
    "foo" and "bar\n", instead of emitting two separate logs for "foo"
    and "bar", the Writer will buffer the input until the newline is
    encountered and write a single log for "foobar".
    
    Performance:
    
    ```
    name             time/op
    Writer/single-4  384ns ± 3%
    Writer/splits-4  488ns ±26%
    
    name             alloc/op
    Writer/single-4  16.0B ± 0%
    Writer/splits-4  16.0B ± 0%
    
    name             allocs/op
    Writer/single-4   2.00 ± 0%
    Writer/splits-4   2.00 ± 0%
    ```
    
    Resolves #929
    abhinav authored Jun 25, 2021
    Copy the full SHA
    d5c2a1a View commit details

Commits on Jun 28, 2021

  1. zapio/writer: More documentation and example test

    Add more documentation and an example test for zapio.Writer to
    demonstrate its usage.
    abhinav committed Jun 28, 2021
    Copy the full SHA
    1797f10 View commit details
  2. Prepare release v1.18.0

    This release contains the following API changes per apidiff:
    
    ```
    --- go.uber.org/zap ---
    Compatible changes:
    - WithClock: added
    --- go.uber.org/zap/buffer ---
    Compatible changes:
    - (*Buffer).WriteByte: added
    - (*Buffer).WriteString: added
    --- go.uber.org/zap/zapcore ---
    Compatible changes:
    - BufferedWriteSyncer: added
    - Clock: added
    - DefaultClock: added
    --- go.uber.org/zap/zaptest/observer ---
    Compatible changes:
    - (*ObservedLogs).Filter: added
    - (*ObservedLogs).FilterLevelExact: added
    ```
    
    In addition to that, this release contains the new `zapio` package
    which, being a completely new package, is also a compatible change.
    abhinav committed Jun 28, 2021
    Copy the full SHA
    80f724f View commit details
  3. Release v1.18.0 (#973)

    Release v1.18.0 of Zap that contains several new features including:
    
    - `zapio.Writer` to treat a logger as an `io.Writer`
    - `zapcore.BufferedWriteSyncer` to buffer log writes in memory
    - `zap.Clock` to control the source of time
    - New filters on `zaptest/observer.Observer`
    
    This PR includes the release commit and some added documentation for
    `zapio.Writer`.
    abhinav authored Jun 28, 2021
    Copy the full SHA
    35f15d1 View commit details
  4. NopLogger: Fix nil Clock panic

    In #897, we added a `zap.Clock` option to control the source of time
    but neglected to set this field on the logger constructed by
    `zap.NewNop`. This has the effect of panicking the Nop logger with a nil
    dereference.
    
    Fix the nil dereference and add checks for the behavior of the Nop
    logger.
    
    Verified that these are the only instantiations of `Logger` in this
    package:
    
    ```
    $ rg '\bLogger\{' *.go
    logger_test.go
    67:                     for _, logger := range []*Logger{grandparent, parent, child} {
    
    logger.go
    71:     log := &Logger{
    86:     return &Logger{
    ```
    
    Refs GO-684
    abhinav committed Jun 28, 2021
    Copy the full SHA
    7ea57ce View commit details
  5. Prepare release v1.18.1

    This tags a patch release of the breakage introduced in 1.18.0.
    abhinav committed Jun 28, 2021
    Copy the full SHA
    a779980 View commit details
  6. Release v1.18.1, fix panic

    This releases a fix for the NopLogger breakage accidentally introduced
    in v1.18.0.
    abhinav authored Jun 28, 2021
    Copy the full SHA
    120b08c View commit details

Commits on Jul 1, 2021

  1. Discard counters for out-of-bounds levels (#975)

    Previously this just crashed.
    
    Co-authored-by: Prashant Varanasi <prashant@uber.com>
    thockin and prashantv authored Jul 1, 2021
    Copy the full SHA
    007a55e View commit details

Commits on Jul 5, 2021

  1. fix typo (#976)

    lancoLiu authored Jul 5, 2021
    Copy the full SHA
    42e70dd View commit details
  2. go mod tidy (#977)

    sywhang authored Jul 5, 2021
    Copy the full SHA
    1cac10b View commit details

Commits on Jul 30, 2021

  1. Copy the full SHA
    81879d1 View commit details
  2. Optimize size of BufferedWriteSyncer by moving stopped bool field (#984)

    Keeping the 2 `bool` fields next to each other avoids wasting an additional word.
    lancoLiu authored Jul 30, 2021
    Copy the full SHA
    2198a43 View commit details

Commits on Aug 9, 2021

  1. Release v1.19.0 (#987)

    abhinav authored Aug 9, 2021
    Copy the full SHA
    c8e813e View commit details

Commits on Aug 13, 2021

  1. Copy the full SHA
    d8fd848 View commit details

Commits on Sep 8, 2021

  1. json: Fix encoding complex with negative i (#1001)

    Fix encoding of complex numbers with negative imaginary components.
    Previously, `2 - 3i` was encoded as the following:
    
        2+-3i
    
    Instead of the following:
    
        2-3i
    
    Fix this by handling negative imaginary components correctly.
    
    Fixes #995
    hemantjadon authored Sep 8, 2021
    Copy the full SHA
    914c4ff View commit details
  2. json: Fix float32 encoding and add test (#1003)

    This commit fixes incorrect float32 encoding. A test
    case is also added.
    
    Refs: 
    * #1002
    * Internal ticket: GO-860
    manjari25 authored Sep 8, 2021
    Copy the full SHA
    305c249 View commit details
  3. Update changelog (#1004)

    This commit adds an unreleased section to the changelog
    to track things that need to be released. It also lists the
    unreleased changes since the last release to this section.
    manjari25 authored Sep 8, 2021
    Copy the full SHA
    0944a26 View commit details
  4. Preparing release v1.19.1 (#1005)

    This commit updates the changelog with release
    notes for v1.19.1.
    manjari25 authored Sep 8, 2021
    Copy the full SHA
    eaeb0fc View commit details
17 changes: 17 additions & 0 deletions .github/workflows/fossa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: FOSSA Analysis
on: push

jobs:

build:
runs-on: ubuntu-latest
if: github.repository_owner == 'uber-go'
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: FOSSA analysis
uses: fossas/fossa-action@v1
with:
api-key: ${{ secrets.FOSSA_API_KEY }}

5 changes: 0 additions & 5 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -26,11 +26,6 @@ jobs:

- name: Checkout code
uses: actions/checkout@v2

- name: FOSSA analysis
uses: fossas/fossa-action@v1
with:
api-key: ${{ secrets.FOSSA_API_KEY }}

- name: Load cached dependencies
uses: actions/cache@v1
56 changes: 56 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,60 @@
# Changelog
All notable changes to this project will be documented in this file.

This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## 1.19.1 (8 Sep 2021)

### Fixed
* [#1001][]: JSON: Fix complex number encoding with negative imaginary part. Thanks to @hemantjadon.
* [#1003][]: JSON: Fix inaccurate precision when encoding float32.

[#1001]: https://github.com/uber-go/zap/pull/1001
[#1003]: https://github.com/uber-go/zap/pull/1003

## 1.19.0 (9 Aug 2021)

Enhancements:
* [#975][]: Avoid panicking in Sampler core if the level is out of bounds.
* [#984][]: Reduce the size of BufferedWriteSyncer by aligning the fields
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.

## 1.18.1 (28 Jun 2021)

Bugfixes:
* [#974][]: Fix nil dereference in logger constructed by `zap.NewNop`.

[#974]: https://github.com/uber-go/zap/pull/974

## 1.18.0 (28 Jun 2021)

Enhancements:
* [#961][]: Add `zapcore.BufferedWriteSyncer`, a new `WriteSyncer` that buffers
messages in-memory and flushes them periodically.
* [#971][]: Add `zapio.Writer` to use a Zap logger as an `io.Writer`.
* [#897][]: Add `zap.WithClock` option to control the source of time via the
new `zapcore.Clock` interface.
* [#949][]: Avoid panicking in `zap.SugaredLogger` when arguments of `*w`
methods don't match expectations.
* [#943][]: Add support for filtering by level or arbitrary matcher function to
`zaptest/observer`.
* [#691][]: Comply with `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

## 1.17.0 (25 May 2021)

49 changes: 26 additions & 23 deletions benchmarks/go.sum
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/apex/log v1.1.1 h1:BwhRZ0qbjYtTob0I+2M+smavV0kOC8XgcnGZcyL9liA=
github.com/apex/log v1.1.1/go.mod h1:Ls949n1HFtXfbDcjiTTFQqkVUrte0puoIBfO3SVgwOA=
github.com/aphistic/golf v0.0.0-20180712155816-02c07f170c5a/go.mod h1:3NqKYiepwy8kCu4PNA+aP7WUV72eXWJeP9/r3/K9aLE=
github.com/aphistic/sweet v0.2.0/go.mod h1:fWDlIh/isSE9n6EPsRmC0det+whmX6dJid3stzu0Xys=
github.com/aws/aws-sdk-go v1.20.6/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
github.com/aybabtme/rgbterm v0.0.0-20170906152045-cc83f3b3ce59/go.mod h1:q/89r3U2H7sSsE2t6Kca0lfwTK8JdoNGS/yzM/4iH5I=
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
@@ -19,12 +19,10 @@ github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V
github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
github.com/jpillora/backoff v0.0.0-20180909062703-3050d21c67d7/go.mod h1:2iMrUgbbvHEiQClaW2NsSzMyGHqN+rDFqY705q49KG0=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515 h1:T+h1c/A9Gawja4Y9mFVWj2vyii2bbUNDw3kt9VxK2EY=
@@ -48,7 +46,6 @@ github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/fastuuid v1.1.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
github.com/rs/zerolog v1.16.0 h1:AaELmZdcJHT8m6oZ5py4213cdFK8XGXkB3dFdAQ+P7Q=
github.com/rs/zerolog v1.16.0/go.mod h1:9nvC1axdVrAHcu/s9taAVfBuIdTZLVQmKQyvrUjF5+I=
@@ -60,63 +57,69 @@ github.com/smartystreets/go-aws-auth v0.0.0-20180515143844-0c1422d1fdb9/go.mod h
github.com/smartystreets/gunit v1.0.0/go.mod h1:qwPWnhz6pn0NnRBP++URONOVyNkPyr4SauJk4cUOwJs=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.3.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/tj/assert v0.0.0-20171129193455-018094318fb0/go.mod h1:mZ9/Rh9oLWpLLDRpvE+3b7gP/C2YyLFYxNmcLnPTMe0=
github.com/tj/go-elastic v0.0.0-20171221160941-36157cbbebc2/go.mod h1:WjeM0Oo1eNAjXGDx2yma7uG2XoyRZTq1uv3M/o7imD0=
github.com/tj/go-kinesis v0.0.0-20171128231115-08b17f58cb1b/go.mod h1:/yhzCV0xPfx6jb1bBgRFjl5lytqVqZXEaeqWP8lTEao=
github.com/tj/go-spin v1.1.0/go.mod h1:Mg1mzmePZm4dva8Qz60H2lHwmJ2loum4VIrLgVnKwh4=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q=
go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/goleak v1.1.11-0.20210813005559-691160354723 h1:sHOAIxRGBp443oHZIPB+HsUGaksVCXVQENPxwTfQdH4=
go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4=
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee h1:0mgffUl7nfd+FpvXMVz4IDEaUSmT1ysygQC7qYo7sG4=
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs=
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007 h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20190828213141-aed303cbaa74/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5 h1:hKsoRgsbwY1NafxrwTs+k64bikrLBkAgPir1TNCj3Zs=
golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA=
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec h1:RlWgLqCMMIYYEVcAR5MDsuHlVkaIPDAF+5Dehzg8L5A=
gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM=
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
18 changes: 18 additions & 0 deletions buffer/buffer.go
Original file line number Diff line number Diff line change
@@ -106,6 +106,24 @@ func (b *Buffer) Write(bs []byte) (int, error) {
return len(bs), nil
}

// WriteByte writes a single byte to the Buffer.
//
// Error returned is always nil, function signature is compatible
// with bytes.Buffer and bufio.Writer
func (b *Buffer) WriteByte(v byte) error {
b.AppendByte(v)
return nil
}

// WriteString writes a string to the Buffer.
//
// Error returned is always nil, function signature is compatible
// with bytes.Buffer and bufio.Writer
func (b *Buffer) WriteString(s string) (int, error) {
b.AppendString(s)
return len(s), nil
}

// TrimNewline trims any final "\n" byte from the end of the buffer.
func (b *Buffer) TrimNewline() {
if i := len(b.bs) - 1; i >= 0 {
4 changes: 3 additions & 1 deletion buffer/buffer_test.go
Original file line number Diff line number Diff line change
@@ -44,10 +44,12 @@ func TestBufferWrites(t *testing.T) {
{"AppendUint", func() { buf.AppendUint(42) }, "42"},
{"AppendBool", func() { buf.AppendBool(true) }, "true"},
{"AppendFloat64", func() { buf.AppendFloat(3.14, 64) }, "3.14"},
// Intenationally introduce some floating-point error.
// Intentionally introduce some floating-point error.
{"AppendFloat32", func() { buf.AppendFloat(float64(float32(3.14)), 32) }, "3.14"},
{"AppendWrite", func() { buf.Write([]byte("foo")) }, "foo"},
{"AppendTime", func() { buf.AppendTime(time.Date(2000, 1, 2, 3, 4, 5, 6, time.UTC), time.RFC3339) }, "2000-01-02T03:04:05Z"},
{"WriteByte", func() { buf.WriteByte('v') }, "v"},
{"WriteString", func() { buf.WriteString("foo") }, "foo"},
}

for _, tt := range tests {
47 changes: 47 additions & 0 deletions clock_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright (c) 2020 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

package zap

import (
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/zap/zaptest/observer"
)

type constantClock time.Time

func (c constantClock) Now() time.Time { return time.Time(c) }
func (c constantClock) NewTicker(d time.Duration) *time.Ticker {
return &time.Ticker{}
}

func TestWithClock(t *testing.T) {
date := time.Date(2077, 1, 23, 10, 15, 13, 441, time.UTC)
clock := constantClock(date)
withLogger(t, DebugLevel, []Option{WithClock(clock)}, func(log *Logger, logs *observer.ObservedLogs) {
log.Info("")
require.Equal(t, 1, logs.Len(), "Expected only one log entry to be written.")
assert.Equal(t, date, logs.All()[0].Entry.Time, "Unexpected entry time.")
})
}
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -3,9 +3,11 @@ module go.uber.org/zap
go 1.13

require (
github.com/benbjohnson/clock v1.1.0
github.com/pkg/errors v0.8.1
github.com/stretchr/testify v1.7.0
go.uber.org/atomic v1.7.0
go.uber.org/goleak v1.1.11-0.20210813005559-691160354723
go.uber.org/multierr v1.6.0
gopkg.in/yaml.v2 v2.2.8
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
Loading