From c4560491e4932ddbc8de8fed031b9005a5c98375 Mon Sep 17 00:00:00 2001 From: Mike Ho Date: Mon, 16 Aug 2010 16:55:12 -0700 Subject: [PATCH] Added full Backtrace logging to QLog --- includes/qcodo/_core/framework/QLog.class.php | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/includes/qcodo/_core/framework/QLog.class.php b/includes/qcodo/_core/framework/QLog.class.php index 4ddc5698..f6cf3afc 100644 --- a/includes/qcodo/_core/framework/QLog.class.php +++ b/includes/qcodo/_core/framework/QLog.class.php @@ -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