librespeed / speedtest-cli

Command line client for LibreSpeed
GNU Lesser General Public License v3.0
487 stars 60 forks source link

--json option giving output for stderr instead stdout #26

Closed blnprasad closed 3 years ago

blnprasad commented 3 years ago

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":""}

maddie commented 3 years ago

Could you please tell me which version are you using?

blnprasad commented 3 years ago

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

maddie commented 3 years ago

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

https://github.com/librespeed/speedtest-cli/blob/67b82aec33b3e2061c941a8bcb749aa41e0103dd/main.go#L14-L26

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

blnprasad commented 3 years ago

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.