Add code to optionally write status file contents to a JSON file #7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR will add two new config options - global:log_json and global:json_file, which control writing a JSON formatted status file. The JSON file contains mostly the same information as the status file, but it's not a like for like copy.
The repository now bundles in kgabis/parson as it's JSON serialiser, which is MIT license (hopefully that's OK).
The code itself is rather poor - I've duplicated the writeStatusFile() function into writeJsonFile(), which means all the status information is queried twice (clock drivers stats, etc). I've done it this way though because it's very easy to merge - there should be only additive changes.
A better way to do this whole thing would be to abstract the gathering of status information into an internal structure that multiple writer functions could reference (it would make it very easy to create a socket writer function then). That's a rather large refactor though, and I didn't want to try take that on if you've got more branches of your own coming. I've also made some questionable calls to data inside the libcck structures that should probably be replaced with get() methods in the future.