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
There's no way to log a line without also including source information of a caller of Log.
When hooking logger implementations up *testing.T so that log messages can be directly associated with a test (particularly important when running parallel tests), the source line is almost always noise, as one of the callers of t.Log will be a function in the logging package, which cannot call Helper. Also the logger
implementation will usually be in a position to add its own annotation.
Unnecessary noise can often be a significant barrier to quick comprehension of test output.
We propose that a new method be added to *testing.T, *testing.B and testing.TB:
// LogClean logs the given arguments similarly to Log, but does
// not decorate the line with file and line number information.
func (t *T) LogClean(args ...interface{})
The text was updated successfully, but these errors were encountered:
For the same reason, I often wanted a io.Writer bound to the test output (and had to implement a bad one on top of T.Log). Sounds like that might be a better solution because it also avoids spurious newlines, and plugs right into log.SetOutput.
I understand your point but in this case it seems like the best choice is to print another file:line after with what you want to indicate. New API for this doesn't seem warranted.
Note that you could also just log all your output to a buffer and print it out at the end as a multiline t.Log, and then you only get one prefix at the start.
There's no way to log a line without also including source information of a caller of Log.
When hooking logger implementations up *testing.T so that log messages can be directly associated with a test (particularly important when running parallel tests), the source line is almost always noise, as one of the callers of t.Log will be a function in the logging package, which cannot call Helper. Also the logger
implementation will usually be in a position to add its own annotation.
Unnecessary noise can often be a significant barrier to quick comprehension of test output.
We propose that a new method be added to *testing.T, *testing.B and testing.TB:
The text was updated successfully, but these errors were encountered: