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

Add JSON output support #2

Closed
gavv opened this issue May 25, 2020 · 3 comments · Fixed by #4
Closed

Add JSON output support #2

gavv opened this issue May 25, 2020 · 3 comments · Fixed by #4
Assignees
Labels
feature New feature or request good first issue Good for newcomers help wanted Contributions are welcome

Comments

@gavv
Copy link
Owner

gavv commented May 25, 2020

Steps:

  • add a new interface IFormatter with methods like report_latency(...) and report_losses(...)
  • add two implementations: TextFormatter (implementing the current output formatting) and JsonFormatter (implementing the new JSON formatting)
  • use IFormatter in LatencyEstimator and LossEstimator instead of raw call to se_log_info()
  • add a command-line option that enables JSON formatter; it it's not specified, use text formatter by default

When JSON is enabled, this output:

latency:  sw+hw  13.145ms  hw   2.934ms  hw_avg5   2.934ms
latency:  sw+hw  12.465ms  hw   2.924ms  hw_avg5   2.929ms
...

should turn to something like this:

[
  {"sw+hw": 13.145, "hw": 2.934, "hw_avg5": 2.934},
  {"sw+hw": 12.465, "hw": 2.924, "hw_avg5": 2.929},
  ...
...
@gavv gavv added feature New feature or request help wanted Contributions are welcome good first issue Good for newcomers labels May 25, 2020
@BitsonFire
Copy link
Contributor

Hi! I'm a beginner to open source contributions and I'd like to work on this issue. I had a doubt regarding the JSON formatting. Do you want to me to use an Json library like JsonCpp for doing that or would just printing it in JSON format be enough?
Thank You!

@gavv
Copy link
Owner Author

gavv commented Jun 13, 2020

Hi, you're welcome.

I think for this small tool it would be enough to print JSON manually without any libraries, given that the format is simple and we never need to parse it, only format.

@gavv
Copy link
Owner Author

gavv commented Jul 12, 2020

Merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request good first issue Good for newcomers help wanted Contributions are welcome
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants