Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reformat and redesign the recording output. (#186)
* Reformat and redesign the recording output. - Formats command events into properly related JSON. - Properly record status responses (ok, warning, errors). - Record API requests as a chain related to each command. - Record the raw command issued, the actual command executed, and the command filter applied (if any). - Moves comment handling to OutputManager. - Consolidates stop_recording and save_recording. - Renamed some variables and methods for consistency. - Recording-related methods now all start with recording_ as a prefix. - Added a command line option to enable or disable timing data from the recorded data. - In general, callers adding details to the recorded data shouldn't test if recording is active. OutputManager handles that detail, the rest of the code simply states that it wishes to make something available for recording. * Issues - The stack details for errors and warnings is bugged. See #185 - We buffer the entire recording blob in memory until we stop recording (or we exit). This is to ensure valid JSON for the output, as writing (valid) JSON streams to a file is non-trivial. A solution is to write after each command, reload the file and append the data, then write again. This may or may not be a good idea, and it would look something like: ```python existing_data = [] # Read the existing data from the file try: with open(self._filename, "r") as rec_file: existing_data = json.load(rec_file) except (FileNotFoundError, json.JSONDecodeError): pass existing_data.append(recording_entry) # Write the updated data back to the file with open(self._filename, "w") as rec_file: json.dump(existing_data, rec_file, indent=2) ```
- Loading branch information