ptpd icon indicating copy to clipboard operation
ptpd copied to clipboard

Add code to optionally write status file contents to a JSON file

Open lukebigum opened this issue 6 years ago • 4 comments

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.

lukebigum avatar Nov 13 '17 17:11 lukebigum