Decode HTML entities for incoming text and pretty-print valid JSON payloads before appending to the log.