Magento Forum

   
Mage::debug()
 
clockworkgeek
Sr. Member
 
Avatar
Total Posts:  79
Joined:  2009-07-31
 

A simple request here.

I like using Mage::log(), it is very handy and I often find myself doing tricks like

Mage::log(__CLASS__.'::'.__FUNCTION__.PHP_EOL.print_r($data,true))
which is messy and long. I know of Varien_Object::debug() but it returns an array which still needs to be print_r-ed or var_dump-ed.

I know there are debug modules and firePHP modules but using those assumes they have been installed. I’ve managed to leave debugging lines in before when copying extensions to production sites, if I were depending on a 3rd party extension it would produce an error.

Rather, I would like to see a simple Mage::debug() function (so I don’t have to overwrite Mage class each time) that takes any variable, uses Varien_Object::debug() where applicable, and prints out the resulting array nicely to it’s own debug.log file. Were it standard in all magento installs then it would be a lot more useful.

Just for comparison this is what I imagine:

Mage::debug($data);

 
Magento Community Magento Community
Magento Community
Magento Community
 
clockworkgeek
Sr. Member
 
Avatar
Total Posts:  79
Joined:  2009-07-31
 

And since I’m making requests it would also be nice if it supported Zend_Log_Writer_Firebug

 
Magento Community Magento Community
Magento Community
Magento Community
 
Damian Culotta
Enthusiast
 
Total Posts:  878
Joined:  2008-12-10
Argentina
 

What about Zend_Debug::dump() ?

 
Magento Community Magento Community
Magento Community
Magento Community
 
clockworkgeek
Sr. Member
 
Avatar
Total Posts:  79
Joined:  2009-07-31
 

I cannot claim to be a fan of Zend_Debug::dump(), it wraps var_dump but is longer to type. And in this situation still needs to be wrapped again in Mage::log().

When dumping to a webpage it does add <pre> tags which is useful.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top