-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: testing Log functions do not capture timestamp #36656
Comments
I don't think this is what most people want. You can add timestamps yourself to your |
for what it's worth, I think it'd be a useful feature as well, for the same reason @vimalk78 provided. |
Agree, have always used timestamps and would rather not have a separate log package/include a TS snippet in each log statement. |
I personally think this would be nice by default; most of the output from
cmd/go's TestScript does something similar; each section of a test script has a comment, and the output includes how long that section took to run (cc @bcmills):
When I write long tests in Go, such as integration tests, I often want similar timestamps or durations to be able to tell what's taking most of the time. It's also useful with Like @ianlancetaylor says, I can always add timestamps or elapsed durations to log calls myself, though at this point I've done that in a handful of different places, and I don't see a reason why we shouldn't do it by default :) I reckon I would generally find this useful for any test which takes more than a tens of milliseconds and prints a few logs. Worth noting that, with |
For the record, my current workaround is:
The logs with
|
For what it's worth, I added absolute timestamps to However, I only added a timestamp at the start of the run: the timestamp at the start combined with the running time of the test give a bounded window in which the events of the test occurred, which was all I really cared about for the purpose (diagnosing test failures caused by errors in non-hermetic external services). |
I think #59928 with the writer passed to a logger would be a better fit |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
https://play.golang.org/p/525R1YDp8sB
Write a test case which calls
t.Log
ort.Logf
The output of these logs is generated when a test fails. If i am using a CI for testing, it makes my job much easier if i can correlate test log timestamps with other logs captured by CI
What did you expect to see?
The
t.Log
statements should produce timestamps.What did you see instead?
No timestamps
The text was updated successfully, but these errors were encountered: