You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
we use some clock testing packages like https://github.com/jonboulle/clockwork
that relies on the tested code not calling directly time.Now()
can we have some interface in the encoder configuration ?
for example TimeSource interface that implemented the time.Now(), and in the zap encoder configuration an option to put your own interface to supply time ?
The text was updated successfully, but these errors were encountered:
This may not be exactly what you're looking for, but perhaps it'll solve your problem: There is a testing package in zap which creates a logger that captures logs in-memory: observer.
core, logs := observer.New(zap.ErrorLevel)
logger := zap.New(core)
// pass in logger to code you'r testing
You can use logs.All() to get all logs, with timestamps, or use AllUntimed() to get all logs without timestamps.
we use some clock testing packages like
https://github.com/jonboulle/clockwork
that relies on the tested code not calling directly time.Now()
can we have some interface in the encoder configuration ?
for example TimeSource interface that implemented the time.Now(), and in the zap encoder configuration an option to put your own interface to supply time ?
The text was updated successfully, but these errors were encountered: