-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
testing: Improve logging from TestAgent #7546
Conversation
Previously the log output included the test name twice and a long date format. The test output is already grouped by test, so adding the test name did not add any new information. The date and time are only useful to understand elapsed time, so using a short format should provide succident detail. Also fixed a bug in NewTestAgentWithFields where nil was returned instead of the test agent.
// default value. Tests which set a custom name for multiple agents will | ||
// use the provided name. | ||
// TODO: remove TestAgent.Name and accept a name arg on Start, to remove | ||
// this workaround. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can make this change after the PR merges. It should be easy to automate, but will change ~800 lines. I did not want all of those changes distracting from the logging changes in this PR.
47e2ec5
to
1ea8456
Compare
And re-add the name to the logger so that log messages from different agents in a single can be identified.
1ea8456
to
ad7c78f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find the log output in tests somewhat difficult to work with.
As an example, here is a log line before this change:
There are 112 characters before the relevant log line text starts. The name is duplicated, and is unnecessary because
go test
already aggregates the output by test. The full date/time is most likely not relevant, either CI will give us the time, or for a local run we know the time. The time is really only relevant to understand the elapsed time between log lines.writer.go:29
is the same on every log line.After this change:
The time is still there, so we can see elapsed time between statements. For the few tests which run multiple agents
TestAgent
will be replaced with the name provided by the test, so we can tell which agent produced the log message.