librespeed/speedtest-cli

--json option giving output for stderr instead stdout

blnprasad opened this issue · 4 comments

when we pass --json option the result being printed on console is stderr instead stdout. Looks like its printing result as stderr instead stdout. it would be really helpful if the result comes as stdout and any errors as part of stderr

./out/librespeed-cli-linux-amd64 --json > file1 2> file2
~/.../speetest/speedtest-cli $ cat file1
~/.../speetest/speedtest-cli $ cat file2
Selected server: Strasbourg, France (Host Europe) [sxb.bandspeed.de]
You're testing from: 122.172.110.47 - Bharti Airtel Ltd., Telemedia Services, IN (7450 km)
{"timestamp":"2021-03-16T17:35:15.3206446+05:30","server":{"name":"Strasbourg, France (Host Europe)","url":"https://sxb.bandspeed.de/"},"client":{"ip":"122.172.110.47","hostname":"abts-kk-dynamic-047.110.172.122.airtelbroadband.in","city":"Bengaluru","region":"Karnataka","country":"IN","loc":"12.9719,77.5937","org":"AS24560 Bharti Airtel Ltd., Telemedia Services","postal":"560002","timezone":"Asia/Kolkata"},"bytes_sent":6291456,"bytes_received":77692920,"ping":206.36363636363637,"jitter":92.92,"upload":3.2,"download":39.52,"share":""}

Could you please tell me which version are you using?

I'm using latest master code. I think this is as result of logging using warn level

All logs should be written to os.Stdout, as seen here:

speedtest-cli/main.go

Lines 14 to 26 in 67b82ae

func init() {
// set logrus formatter and default log level
formatter := &defs.NoFormatter{}
// debug level is for --debug messages
// info level is for non-suppress mode
// warn level is for suppress modes
// error level is for errors
log.SetOutput(os.Stdout)
log.SetFormatter(formatter)
log.SetLevel(log.InfoLevel)
}

I'll have to verify this later, been very busy IRL.

yes. you are correct. I was using master branch where things are not proper. its as expected with v1.0.7 branch. Thanks for looking into it.