Skip to content

Commit

Permalink
Remove std log Set Output
Browse files Browse the repository at this point in the history
The current way to set the std log output generates an io.Writer
but it never closes it so the goleaks detects an anomaly.
The std log shouldn't be used so let's remove it.
  • Loading branch information
codebien committed Dec 23, 2022
1 parent 15314f7 commit 8d033d1
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 6 deletions.
2 changes: 0 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"fmt"
"io"
"io/ioutil"
stdlog "log"
"os"
"os/signal"
"path/filepath"
Expand Down Expand Up @@ -242,7 +241,6 @@ func (c *rootCommand) persistentPreRunE(cmd *cobra.Command, args []string) error
c.loggerIsRemote = true
}

stdlog.SetOutput(c.globalState.logger.Writer())
c.globalState.logger.Debugf("k6 version: v%s", consts.FullVersion())
return nil
}
Expand Down
5 changes: 1 addition & 4 deletions cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@ func TestMain(m *testing.M) {
}()

defer func() {
// TODO: figure out why logrus' `Entry.WriterLevel` goroutine sticks
// around and remove this exception.
opt := goleak.IgnoreTopFunction("io.(*pipe).read")
if err := goleak.Find(opt); err != nil {
if err := goleak.Find(); err != nil {
fmt.Println(err) //nolint:forbidigo
exitCode = 3
}
Expand Down

0 comments on commit 8d033d1

Please sign in to comment.