function trace($text = false, $stack_frames_to_discard = 0) { if (!fbDebug::debugging()) { return ''; } if ((fbDebug::getLevel() & FB_DEBUG_TRACE) != FB_DEBUG_TRACE) { return ''; } // fbDebug::stackdump(); $s = ''; if (function_exists('debug_backtrace')) { $callstack = debug_backtrace(); //print_r($callstack); //exit; // remove the call to create a new Callstack while ($stack_frames_to_discard-- > 0) { array_shift($callstack); } $s = ''; foreach ($callstack as $call) { $args = array(); $class = ''; $file = ''; $function = ''; $line = 0; $type = ''; extract($call); if ($function == 'fb_assert_handler') { continue; } $s = sprintf("%-30s: %s (%s)\n", basename($file) . '(' . $line . ')', $text, $file); break; } } elseif (function_exists('apd_callstack')) { $callstack = apd_callstack(); // remove the call to create a new Callstack while ($stack_frames_to_discard-- > 0) { array_shift($callstack); } $s = "\n<tt>\nCall Stack:\n</tt>\n"; foreach ($callstack as $call) { $file = $call[1]; $line = $call[2]; $frame = $call[0] . '(' . implode(', ', $call[3]) . ')'; $s .= sprintf("\n<pre>\t%-30s: %s\t(%s)</pre>\n", basename($file) . '(' . $line . ')', $frame, $file); } $s .= "\n<br />\n"; } else { return ''; } /* if (function_exists('apd_callstack')) { $callstack = apd_callstack(); $call = array_shift($callstack); $s .= sprintf('%s(%d) [', basename($call[1]) , $call[2]); $call = array_shift($callstack); $s .= $call[0] . '('; if (is_array($call[3])) $s .= implode(', ', $call[3]); $s .= ')'; } */ $s = fbDebug::pre($s); $s = fbDebug::log($s); return $s; }
public static function logToDataBases($level, $class, $fonction, $prefixStr, $params = '') { $tableName = 'log'; $fields = 'date, ticks , className , functionName , title, text, callstack'; $valuesFormat = '\'%s\', %f, \'%s\', \'%s\', %d, %s, \'%s\' '; $query = ''; if (defined(LOGTODATABASE) && LOGTODATABASE == TRUE && Logger::isDebugEnabled()) { if (Logger::$pool == null) { Logger::$pool = new databasePDO(); } $message = ' ' . $prefixStr . ' ' . Logger::getString($params); $values = sprintf($valuesFormat, date('Y-m-d H:i:s', time()), microtime(true) - (double) $_SERVER['REQUEST_TIME'], $class, $fonction, $level, Logger::$pool->ValidSGBDString($message), ADDCALLSTACKLOG == TRUE ? Logger::getString(apd_callstack()) : ''); $query = sprintf(Logger::QUERYFORMAT, $tableName, $fields, $values); Logger::$pool->ExecuteQuery($query); } }