Write a Python script to parse a deeply nested JSON log file, flatten the structure, and handle missing or malformed fields.