Skip to content

proposal: testing: implement io.Writer with T and B #28778

@poy

Description

@poy

Problem

Tests that have to create a *log.Logger do not (at least not out of the box) get to take advantage of testing's T.Log and the nice features that come with it.

This implies test writers have to either wrap T.Log up to make it implement io.Writer somehow and pass that into log.New(tlogger, "", 0), or discard their logs all together (e.g., log.New(ioutil.Discard, "", 0)).

Solution

Have testing.T and testing.B implement io.Writer.

This will allow developers to simply create a log.Logger by doing log.New(t, "", 0). It would also be compatible with most other logging libraries.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions