Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Import of this package will destroy logging #127

Closed
srebhan opened this issue May 30, 2023 · 3 comments · Fixed by influxdata/telegraf#13369
Closed

BUG: Import of this package will destroy logging #127

srebhan opened this issue May 30, 2023 · 3 comments · Fixed by influxdata/telegraf#13369

Comments

@srebhan
Copy link

srebhan commented May 30, 2023

A simple import of the speedtest package will destroy logging of a parent applications as the following code shows...

package main

import (
        "log"
        _ "github.com/showwin/speedtest-go/speedtest"
)

func main() {
        log.Fatalln("This will never be shown!")
}

Running this code will NOT produce any output while removing the import of "github.com/showwin/speedtest-go/speedtest" will bring back logging. I was able to trace down the issue to line 174 of speedtest.go which globally sets the logging target to io.discard thus unexpectedly discarding ALL logging messages of the application. Furthermore, the wrapping New() function is called in line 193 of the same file on import.

Please remove the call to log.SetOutput(io.Discard) as this has sever side-effects to applications using your package, e.g. Telegraf.

@r3inbowari
Copy link
Collaborator

It has been removed. I'm sorry for the trouble🥺. @srebhan @powersj,

@srebhan
Copy link
Author

srebhan commented May 31, 2023

@r3inbowari no worries! Thanks for the quick fix!

@srebhan
Copy link
Author

srebhan commented May 31, 2023

I can confirm this works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants