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: Extend ObservableLogs to support filtering #383

Closed
prashantv opened this issue Mar 23, 2017 · 1 comment
Closed

zaptest: Extend ObservableLogs to support filtering #383

prashantv opened this issue Mar 23, 2017 · 1 comment

Comments

@prashantv
Copy link
Collaborator

In tests, it's useful to validate that a specific log exists with a specific field (similar to tchannel's log filtering).

I'm thinking of adding methods on ObservedLogs to filter:

  • filter by message (exact or substring, not sure)
  • filter by exact field match (key and value)
  • filter by level

Imagining something like:

logger, sink := observer.New(...)
[...]
logs := sink.FilterMessage("Warning.").FilterField("serviceName", "foo")
assert.Equal(t, 1, logs.Len(), "Missing expected log in %v", sink)

cc @billf

@akshayjshah
Copy link
Contributor

Sounds good to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants