Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zaptest: Add testing.TB compatible logger #518

Merged
merged 17 commits into from
Apr 12, 2018
Merged

Commits on Oct 31, 2017

  1. zaptest: Add testing.TB compatible logger

    This adds `zaptest.NewTestLogger(testing.TB) *zap.Logger` and a
    level-override variant of it. This will enable us to use non-nop loggers
    from tests without spamming the output.
    
    These loggers will not print any output unless the test failed or
    `go test -v` was used.
    abhinav committed Oct 31, 2017
    Configuration menu
    Copy the full SHA
    4f818a2 View commit details
    Browse the repository at this point in the history
  2. Rename to zaptest/tlogger

    abhinav committed Oct 31, 2017
    Configuration menu
    Copy the full SHA
    be2b5ea View commit details
    Browse the repository at this point in the history
  3. Remove backticks

    abhinav committed Oct 31, 2017
    Configuration menu
    Copy the full SHA
    a73cb3f View commit details
    Browse the repository at this point in the history
  4. Revert "Remove backticks"

    This reverts commit a73cb3f.
    abhinav committed Oct 31, 2017
    Configuration menu
    Copy the full SHA
    e78537e View commit details
    Browse the repository at this point in the history
  5. Revert "Rename to zaptest/tlogger"

    This reverts commit be2b5ea.
    abhinav committed Oct 31, 2017
    Configuration menu
    Copy the full SHA
    9c4600e View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    316a110 View commit details
    Browse the repository at this point in the history

Commits on Nov 1, 2017

  1. Rely on subset of testing.TB interface

    This declares a TestingT interface which is a subset of the
    functionality provided by testing.TB, and changes zaptest to rely on
    that.
    
    This also means that zaptest no longer imports the "testing" package.
    abhinav committed Nov 1, 2017
    Configuration menu
    Copy the full SHA
    ca6ac7d View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    660acc6 View commit details
    Browse the repository at this point in the history

Commits on Feb 21, 2018

  1. Configuration menu
    Copy the full SHA
    4de70e3 View commit details
    Browse the repository at this point in the history

Commits on Mar 26, 2018

  1. Use bytes.TrimRight instead of manual trimming

    Also, no explicit string conversion
    abhinav committed Mar 26, 2018
    Configuration menu
    Copy the full SHA
    959d416 View commit details
    Browse the repository at this point in the history
  2. test: All levels for happy case

    This tests all log levels for the happy case.
    abhinav committed Mar 26, 2018
    Configuration menu
    Copy the full SHA
    063f7a1 View commit details
    Browse the repository at this point in the history
  3. testLogSpy: Logf should log the message

    testLogSpy was logging the `args`, not the actual string.
    abhinav committed Mar 26, 2018
    Configuration menu
    Copy the full SHA
    8dd84b6 View commit details
    Browse the repository at this point in the history
  4. testingWriter: Return original length

    testingWriter should return the length of the original slice, not the
    trimmed slice.
    abhinav committed Mar 26, 2018
    Configuration menu
    Copy the full SHA
    3ebc5fc View commit details
    Browse the repository at this point in the history

Commits on Apr 2, 2018

  1. zaptest: Expand TestingT interface

    This expands the TestingT interface to a much larger subset of
    `testing.TB`.
    
    The following were left out:
    
    - `Error` and `Log` were left out in favor of `Errorf` and `Logf`
    - `Fatal*` methods were left out in favor of `Errorf` followed by
      `FailNow`
    - `Skip*` methods were left out because our test logger shouldn't be
      skipping tests
    - `Helper` was left out because not all supported verisons of Go have
      that
    abhinav committed Apr 2, 2018
    Configuration menu
    Copy the full SHA
    cdd3f0b View commit details
    Browse the repository at this point in the history
  2. zaptest/NewLogger: fail test on internal errors

    Zap's errorOutput is used exclusively to log internal errors. If this
    ever gets used in a test, something catastrophic happened and we should
    fail the test.
    
    This changes the logger returned by zaptest.NewLogger to implement this
    behavior by passing a `WriteSyncer` to `zap.ErrorOutput` that marks the
    test as failed upon being used.
    
    To test this, we set up a test logger and replace its core with one that
    will always fail to write.
    abhinav committed Apr 2, 2018
    Configuration menu
    Copy the full SHA
    2b3338c View commit details
    Browse the repository at this point in the history
  3. zaptest: testLogSpy doesn't have to be thread-safe

    This simplifies the implementation of testLogSpy by removing all
    thread-safety from it. It's only used from these specific tests and
    never concurrently.
    abhinav committed Apr 2, 2018
    Configuration menu
    Copy the full SHA
    d7b6a16 View commit details
    Browse the repository at this point in the history

Commits on Apr 12, 2018

  1. zaptest/NewLogger: Clarify default log level

    This documents that loggers built with zaptest.NewLogger default to
    debug level logging.
    abhinav committed Apr 12, 2018
    Configuration menu
    Copy the full SHA
    d0af2be View commit details
    Browse the repository at this point in the history