In my error handling process, I am dumping a $obj_to_log = print_r($obj,true)
output to my error logs (file/db/redis).
Sometimes $obj is too big, and it will crash at this point (as this essentially duplicate the memory footprint held by the object).
Is there a way I can dump such big objects to file (beside continually increasing memory).
The object currently causing me issues is a Third party library, I can't modify/optimize the object itself.
While right now the problem is caused by only one object, I need my error handling to be robust and be able to handle any object, not all of them (objects in the world) have a __tostring or other error reporting mechanizes.
The reason I serialize the object into a variable is implementation reason, I gather the info in one place, and write to the relevant log type in another place. I guess I can solve this by passing the function that generates the info into the relevant logger class, instead of just the data.