Skip to content

proposal: testing: provide a way to log a line without a source location #23747

Description

@rogpeppe

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{})

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions