Skip to content

Commit

Permalink
Added full Backtrace logging to QLog
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeho committed Aug 16, 2010
1 parent d0e2bf3 commit c456049
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions includes/qcodo/_core/framework/QLog.class.php
Expand Up @@ -99,6 +99,36 @@ public static function LogObject($objObject, $intLogLevel = QLogLevel::Normal, $
}
}

/**
* Used to log the current backtrace.
* @param integer $intLogLevel
* @param string $strLogModule
* @return void
*/
public static function LogBackTrace($intLogLevel = QLogLevel::Normal, $strLogModule = 'default') {
$objBackTrace = debug_backtrace();
$strMessage = null;
for ($intIndex = 1; $intIndex < count($objBackTrace); $intIndex++) {
$objItem = $objBackTrace[$intIndex];

$strKeyFile = (array_key_exists('file', $objItem)) ? $objItem['file'] : '';
$strKeyLine = (array_key_exists('line', $objItem)) ? $objItem['line'] : '';
$strKeyClass = (array_key_exists('class', $objItem)) ? $objItem['class'] : '';
$strKeyType = (array_key_exists('type', $objItem)) ? $objItem['type'] : '';
$strKeyFunction = (array_key_exists('function', $objItem)) ? $objItem['function'] : '';

$strMessage .= sprintf("#%s %s(%s): %s%s%s()\r\n",
$intIndex,
$strKeyFile,
$strKeyLine,
$strKeyClass,
$strKeyType,
$strKeyFunction);
}

self::Log(trim($strMessage), $intLogLevel, $strLogModule);
}

/**
* Internally used function to properly format (with linebreaks and indentation) the message
* @param string $strMessage
Expand Down

0 comments on commit c456049

Please sign in to comment.