Home » Blogs » Magento Debugging Environment

Magento Debugging Environment

How to debug code? (through log)Here we can see debugging code technique:

For File Log System:

system log, exception log and your log file
First need to Enable Log settings from admin:
Go to Admin -> System -> Configuration -> Developer -> Log Settings -> Enable.
The log files for both system and exception stores in {{base_dir}}/var/log.
To do system log we have to use “Mage::log()” and to do exception log we have to use “Mage::logException()”.
Ex:
Write your log:
Mage::log(“For Testing”);
Mage::log(“For Testing”, null, “ourfile.log”);
Mage::logException(“Test log Exception”);

Write Debug Backtrace:

Put it in a function which we have to check where it is called
$tracelog = Varien_Debug::backtrace(true, true);
Mage::log($tracelog);
OR
Mage::log(Varien_Debug::backtrace(true, true), null, ‘backtrace.log’);

Log Class/Method:

Mage::log( get_class($object)) # name of class
Mage::log( get_class_methods($object)) # methods of class

Write Your Profiler in between code:

We can use following line for write a profile section with own tags/keyword
We can use your own keyword which is display in profiler.
Ex:
Varien_Profiler::start(‘YOUR_OWN_KEYWORD’);
$this->_afterLoad();
Varien_Profiler::stop(‘YOUR_OWN_KEYWORD’);
Note: keyword must be same in start and stop