Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
In DEBUG mode, display stack trace in errors
Browse files Browse the repository at this point in the history
  • Loading branch information
cdujeu committed Jan 16, 2014
1 parent a3104aa commit ac0c6df
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
20 changes: 18 additions & 2 deletions core/src/core/classes/class.AJXP_XMLWriter.php
Expand Up @@ -201,11 +201,27 @@ public static function renderNodeArray($array)
*/
public static function catchError($code, $message, $fichier, $ligne, $context)
{
if(error_reporting() == 0) return ;
if(error_reporting() == 0) {
return ;
}
AJXP_Logger::error(basename($fichier), "error l.$ligne", array("message" => $message));
$loggedUser = AuthService::getLoggedUser();
if (ConfService::getConf("SERVER_DEBUG") || ( $loggedUser != null && $loggedUser->isAdmin() )) {
$message .= " in $fichier (l.$ligne)";
$stack = debug_backtrace();
$stackLen = count($stack);
for ($i = 1; $i < $stackLen; $i++) {
$entry = $stack[$i];

$func = $entry['function'] . '(';
$argsLen = count($entry['args']);
for ($j = 0; $j < $argsLen; $j++) {
$func .= $entry['args'][$j];
if ($j < $argsLen - 1) $func .= ', ';
}
$func .= ')';

$message .= "\n". str_replace(dirname(__FILE__), '', $entry['file']) . ':' . $entry['line'] . ' - ' . $func . PHP_EOL;
}
}
if(!headers_sent()) AJXP_XMLWriter::header();
AJXP_XMLWriter::sendMessage(null, SystemTextEncoding::toUTF8($message), true);
Expand Down
7 changes: 2 additions & 5 deletions core/src/plugins/log.text/class.textLogDriver.php
Expand Up @@ -183,12 +183,9 @@ public function stackFlush()
*/
public function close()
{
$success = @fclose($this->fileHandle);
if ($success === false) {
// Failure to close the log file
// error_log("AJXP_Logger failed to close the handle to the log file");
if(is_resource($this->fileHandle)){
fclose($this->fileHandle);
}

}

/**
Expand Down

0 comments on commit ac0c6df

Please sign in to comment.