This question is generic, and I would simply like to know how to dump objects to log files. In order to clarify things, i am elaborating through an example.
I have been successfully using magento observers to call methods when certain events happen.
As an example, I am observing for when a shipment is saved via :
<sales_order_shipment_save_after>
and i’m successfully calling a method. I would like to grab the shipment and simply dump the object to a log file. eg.
public function newShipment(Varien_Event_Observer $observer)
{
$shipment = $observer->getEvent()->getShipment();
$shipId = $shipment->getId();
Mage::log("shipment ({$shipId}) created/saved", null, 'shipments.log');
//trying to dump $shipment data into the log file
Mage::log("({var_dump($shipment)}) ------", null, 'shipments.log');
Mage::log("----------------------------", null, 'shipments.log');
}
The shipment id is printed into the log file just fine, but obviously it does not dump the object the way i want it to as the code I have written is wrong.
Can anyone tell me how I could dump an object to a log file and perhaps give me some advice on logging in general?
thanks very much.
If you are in Developer Mode you can try if the object supports debug output via
$object->debug().