- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 101
--json docs + Readme #669
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
--json docs + Readme #669
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks. I left some suggestions.
book/src/printers.md
Outdated
@@ -5,10 +5,13 @@ The following printers are currently available: | |||
|
|||
- [`probe-run`], parses data sent over RTT (ARM Cortex-M only). | |||
> 💡 If you are using the git version of defmt, make sure you also install the tool from git and not crates.io. | |||
|
|||
Since v0.3.3, `probe-run` has now a [`--json`] flag to format the output. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should say that the main goal of --json is to produce machine readable output. one of the use cases for that is changing the human-readable format
book/src/json-output.md
Outdated
@@ -72,6 +75,47 @@ Afterwards `levels.json` looks like this: | |||
|
|||
It indicates the version of the json format you are using. `probe-run` will always output it as a header at the beginning of each stream of logs. We anticipate that the format will slightly change while `probe-run` and `defmt` evolve. Using this version you always know which revision is in use and can act upon that. | |||
|
|||
> 🤔: What if I want formatted output? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this questions overlaps with the one that says "what can I do with the JSON output?". I would suggest simply mentioning that one use case is changing the human readable output and the piped command. jq
without any flags is not a good example of human readable output, maybe change it to only show the data
field?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can also remove the whole reference to jq
, as it is not relevant information here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not part of this PR but could you fix this line; it has a missing link:
To do that, we supply a few things in [defmt_json_schema]:
book/src/json-output.md
Outdated
@@ -68,6 +71,19 @@ Afterwards `levels.json` looks like this: | |||
{"data":"println","host_timestamp":1643113389707313290,"level":null,"location":{"file":"src/bin/levels.rs","line":15,"module_path":{"crate_name":"levels","modules":[],"function":"__cortex_m_rt_main"}},"target_timestamp":"4"} | |||
``` | |||
|
|||
One use case is changing the human readable output with a piped command. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest moving this addition to the very end and mention that jq
is an existing tool that can be used to change the output format. But again, the example output should be be JSON but something more readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean what is above, or what is under?
{
"data": "I am a PRINTLN-statement",
"host_timestamp": 1647942992494142200,
"level": null,
"location": {
//...
}
},
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But again, the example output should be be JSON but something more readable.
should not be JSON.
by "example output" I meant the code block. Ideally, it should be something like
$ cargo r --example foo | jq "something here"
I am a PRINTLN-statement
the next log statement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest moving this addition to the very end and mention that
jq
is an existing tool that can be used to change the output format. But again, the example output should be be JSON but something more readable.
Dumb question, do you mean at the very end of the page or the very end of the paragraph? I fear it will be a bit out of context at the very end of the page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant at the end of the page. After re-reading the page I think a good place may be after the first paragraph of the "Data transfer objects"
So, what can I do with the JSON output?
There really are no boundaries. (..)
(NEW) One option is to use a program likejq
to extract the parts of interest. blah blah show console example
If you wish to deserialize (..)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe that sentence is enough ⬆️ . Everybody already saw a json output. The console example does not bring anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, the sentence can be enough but I guess it should say "pipe to a program like jq
" instead of "use"
I don't think the link is very informative... I will remove the linking instead, since Johann wrote extensive information. |
I think the link still helps because you can tell it's a crate and what version it's available. |
thanks! |
Build succeeded: |
--json
flag)