I am building a CLI app that imports and uses github.com/docker/docker/pkg/proxy.
The imported package uses a global instance of logrus to log events, for example: https://github.com/docker/docker/blob/master/pkg/proxy/udp_proxy.go#L115
This causes logrus to send the events directly to my stdout
, which pollutes my output.
I tried importing github.com/Sirupsen/logrus
into my main.go
and tried forcing the output to be discarded: logrus.SetOutput(ioutil.Discard)
.
However, that doesn't seem to have any effect on the output from the imported packages.
After some investigation, I noticed that the cause of the problem is vendoring. I have logrus installed in github.com/me/myproject/vendor/github.com/Sirupsen/logrus
. The library I am using has logrus installed in github.com/me/myproject/vendor/docker/docker/vendor/github.com/Sirupsen/logrus
.
I have created a test project and was able to reproduce this problem.
Is there anyway to control and configure logrus when it is used by third-party packages with vendoring?