Prevent errors due to degenerate JSON in debug/subcall payloads
Bug: T380828
First commit: make the logger dependency-injectable.
Second commit: fail gracefully and log when JSON.parse fails; test that logs are emitted in Python.
Third commit: ensure that all metadata keys and values are strings, BY FORCE. Test this behavior in JS.
Fourth commit: also test (in Python) the case where a payload parses as JSON but lacks the expected structure.