// Added debug function Tools::debug_backtrace()

This commit is contained in:
Damien Metzger
2013-07-31 18:30:17 +02:00
parent 33951c1834
commit e930d40482
2 changed files with 39 additions and 3 deletions
+27
View File
@@ -776,6 +776,33 @@ class ToolsCore
{
return (Tools::dieObject($object, $kill));
}
public static function debug_backtrace($start = 0, $limit = null)
{
$backtrace = debug_backtrace();
array_shift($backtrace);
for ($i = 0; $i < $start; ++$i)
array_shift($backtrace);
echo '
<div style="margin:10px;padding:10px;border:1px solid #666666">
<ul>';
$i = 0;
foreach ($backtrace as $id => $trace)
{
if ((int)$limit && (++$i > $limit ))
break;
$relative_file = (isset($trace['file'])) ? 'in /'.ltrim(str_replace(array(_PS_ROOT_DIR_, '\\'), array('', '/'), $trace['file']), '/') : '';
$current_line = (isset($trace['line'])) ? ':'.$trace['line'] : '';
echo '<li>
<b>'.((isset($trace['class'])) ? $trace['class'] : '').((isset($trace['type'])) ? $trace['type'] : '').$trace['function'].'</b>
'.$relative_file.$current_line.'
</li>';
}
echo '</ul>
</div>';
}
/**
* ALIAS OF dieObject() - Display an error with detailed object but don't stop the execution
+12 -3
View File
@@ -51,7 +51,7 @@ class PrestaShopExceptionCore extends Exception
</style>';
echo '<div id="psException">';
echo '<h2>['.get_class($this).']</h2>';
echo $this->getExentedMessage();
echo $this->getExtendedMessage();
$this->displayFileDebug($this->getFile(), $this->getLine());
@@ -145,14 +145,23 @@ class PrestaShopExceptionCore extends Exception
{
$logger = new FileLogger();
$logger->setFilename(_PS_ROOT_DIR_.'/log/'.date('Ymd').'_exception.log');
$logger->logError($this->getExentedMessage(false));
$logger->logError($this->getExtendedMessage(false));
}
/**
* @deprecated 1.5.5
*/
protected function getExentedMessage($html = true)
{
Tools::displayAsDeprecated();
return $this->getExtendedMessage($html);
}
/**
* Return the content of the Exception
* @return string content of the exception
*/
protected function getExentedMessage($html = true)
protected function getExtendedMessage($html = true)
{
$format = '<p><b>%s</b><br /><i>at line </i><b>%d</b><i> in file </i><b>%s</b></p>';
if (!$html)