当前位置: 首页>>代码示例>>PHP>>正文


PHP debug_backtrace函数代码示例

本文整理汇总了PHP中debug_backtrace函数的典型用法代码示例。如果您正苦于以下问题:PHP debug_backtrace函数的具体用法?PHP debug_backtrace怎么用?PHP debug_backtrace使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了debug_backtrace函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: startTimer

 /**
  * Start an benchmarking timer.
  *
  * @param string $name The name of the timer to start.
  * @param string $message A message for your timer
  * @return bool true
  * @static
  **/
 function startTimer($name = null, $message = null)
 {
     $start = getMicrotime();
     $_this = DebugKitDebugger::getInstance();
     if (!$name) {
         $named = false;
         $calledFrom = debug_backtrace();
         $_name = $name = Debugger::trimpath($calledFrom[0]['file']) . ' line ' . $calledFrom[0]['line'];
     } else {
         $named = true;
     }
     if (!$message) {
         $message = $name;
     }
     $_name = $name;
     $i = 1;
     while (isset($_this->__benchmarks[$name])) {
         $i++;
         $name = $_name . ' #' . $i;
     }
     if ($i > 1) {
         $message .= ' #' . $i;
     }
     $_this->__benchmarks[$name] = array('start' => $start, 'message' => $message, 'named' => $named);
     return true;
 }
开发者ID:masayukiando,项目名称:cakephp1.3-mailmagazine,代码行数:34,代码来源:debug_kit_debugger.php

示例2: loadSorterProcessor

 /**
  * Carga un procesador de filtros para el tipo de formato indicado, de no indicarse ningna 
  * usara la implementacion en JSON.
  * 
  * De especificarse el tipo de filtro de existir tratara de cargar la especifica.
  * 
  * Los tipos de procesadores de filtro permitidos son:
  * 'json', 'xml','csv'
  * 
  * Importante : Se asume que si se usan los filtros default , en el include paht default
  * deben estar la referencia a los mismos. (Por ahora estan en config.php).
  *
  * @param $sorter_basename , El nombre base del sorter , por ejemplo "pfilter" que es el defualt
  * para el nombre base de un filtro.
  *
  * @param $sorter_id , el identificador del tipo de sorter tales como  : 'json',
  * 'csv','xml'. De no indicarse se tratara de cargar la generica para json, 
  *
  * @return TSLIFilterProcessor una referencia al Procesador de Filtros o una 
  * excepcion de programacion si el untipo de filtro no esta soportado soportada
  *
  */
 public static function loadSorterProcessor($sorter_basename = null, $sorter_id = null)
 {
     //$defaultDBDriver = TSLUtilsHelper::getDefaultDatabaseDriver();
     $isUserFilter = true;
     // Si no hay tipo de filtro definido usamos JSON por default
     if (!isset($sorter_id) || is_null($sorter_id)) {
         $sorter_id = 'json';
     }
     // Si no hay nombre base de procesador de filtro usamos los predefinidos
     // de lo contrario se respetara el del usuario.
     if (!isset($sorter_basename) || is_null($sorter_basename)) {
         $sorter_basename = 'TSLSorterProcessor';
         $isUserFilter = false;
     }
     // Si se ha indicado tipo de filtro vemos que este entre los permitidos.
     if (isset($sorter_id) and in_array($sorter_id, self::$supported_filters) == FALSE) {
         $backtrace = debug_backtrace();
         throw new TSLProgrammingException($sorter_id . ' tipo de filtro no soportado , Source= ' . $backtrace[0]['file'] . '-(' . $backtrace[0]['line'] . ')');
     } else {
         // Si es un procesador de usuario lo incluimos , debemos decir
         // que los sorters de usuario deberan estar en el APPPATH dentro del directorio
         // request/sorters y el nombre del archivo y clase deberan estar compuestos por el nombre
         // base seguido del tipo de Filtro  con la primera letra capitalizada.
         // Ejemplo : MiFiltroJson, MiSuperFiltroCsv , etc.
         if ($isUserFilter) {
             require_once APPPATH . 'request/sorters/' . $sorter_basename . ucfirst($sorter_id) . EXT;
         }
         // Creamos la instancia del filtro.
         $sorter_basename .= ucfirst($sorter_id);
         return new $sorter_basename();
     }
 }
开发者ID:caranaperu,项目名称:atletismo,代码行数:54,代码来源:TSLSorterProcessorLoaderHelper.php

示例3: event_logging_find_source

/**
 * This routine is used for automatically determining the source for an
 * event that has to be logged. It can determine the source by using either
 * a trace back depth level for examining the call stack or by using
 * the name of a file for which the event happened.
 *
 * The depth level is used to find the caller file by looking at a
 * debug_backtrace() array at the given level. The level might not be the
 * same for all requests, because some logged events will take multiple
 * steps before hitting the log writing functions (for example the database
 * error logging will run through an extra function call).
 *
 * The file that generated the event can also be passed as the $file
 * parameter. In that case, the code will directly use that parameter
 * and not investigate the call stack at all.
 *
 * @param $level   - The call stack depth at which the event generating
 *                   file can be found.
 * @param $file    - The file name of the file that generated the event or
 *                   NULL if this file name is unknown.
 *
 * @return $source - A string that can be used as the event source.
 */
function event_logging_find_source($level = 0, $file = NULL)
{
    $source = NULL;
    $from_module = FALSE;
    // Determine the file that generated the event.
    if ($file === NULL) {
        if (function_exists('debug_backtrace')) {
            $bt = debug_backtrace();
            if (isset($bt[$level]["file"])) {
                $file = $bt[$level]["file"];
            }
        }
    }
    // See if the file belongs to a module.
    if ($file !== NULL) {
        $moddir = preg_quote(dirname(dirname(__FILE__)), '!');
        if (preg_match("!^{$moddir}/([^/]+)/!", $file, $m)) {
            $source = $m[1];
            $from_module = TRUE;
        }
    }
    // No module found? Then the logging is probably done by a regular
    // Phorum page. We can use the phorum_page constant as the source here.
    if ($source === NULL) {
        if (defined("phorum_page")) {
            $source = phorum_page;
        } elseif (defined('PHORUM_ADMIN')) {
            $source = "admin";
        } else {
            $source = "unknown";
        }
    }
    return array($source, $from_module);
}
开发者ID:netovs,项目名称:Core,代码行数:57,代码来源:event_logging.php

示例4: render

 public function render($layout, $args = array())
 {
     // prevent render to recurse indefinitely
     static $count = 0;
     $count++;
     if ($count < self::MAX_RENDER_RECURSIONS) {
         // init vars
         $parts = explode($this->_separator, $layout);
         $this->_layout = preg_replace('/[^A-Z0-9_\\.-]/i', '', array_pop($parts));
         // render layout
         if ($__layout = JPath::find($this->_getPath(implode(DIRECTORY_SEPARATOR, $parts)), $this->_layout . $this->_extension)) {
             // import vars and layout output
             extract($args);
             ob_start();
             include $__layout;
             $output = ob_get_contents();
             ob_end_clean();
             $count--;
             return $output;
         }
         $count--;
         // raise warning, if layout was not found
         JError::raiseWarning(0, 'Renderer Layout "' . $layout . '" not found. (' . YUtility::debugInfo(debug_backtrace()) . ')');
         return null;
     }
     // raise warning, if render recurses indefinitly
     JError::raiseWarning(0, 'Warning! Render recursed indefinitly. (' . YUtility::debugInfo(debug_backtrace()) . ')');
     return null;
 }
开发者ID:bizanto,项目名称:Hooked,代码行数:29,代码来源:renderer.php

示例5: __construct

 private function __construct($slug)
 {
     $this->_slug = $slug;
     $this->_logger = FS_Logger::get_logger(WP_FS__SLUG . '_' . $slug, WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK);
     $bt = debug_backtrace();
     $i = 1;
     while ($i < count($bt) - 1 && false !== strpos($bt[$i]['file'], DIRECTORY_SEPARATOR . 'freemius' . DIRECTORY_SEPARATOR)) {
         $i++;
     }
     $this->_plugin_main_file_path = $bt[$i]['file'];
     $this->_plugin_dir_path = plugin_dir_path($this->_plugin_main_file_path);
     $this->_plugin_basename = plugin_basename($this->_plugin_main_file_path);
     $this->_plugin_data = get_plugin_data($this->_plugin_main_file_path);
     $base_name_split = explode('/', $this->_plugin_basename);
     $this->_plugin_dir_name = $base_name_split[0];
     if ($this->_logger->is_on()) {
         $this->_logger->info('plugin_main_file_path = ' . $this->_plugin_main_file_path);
         $this->_logger->info('plugin_dir_path = ' . $this->_plugin_dir_path);
         $this->_logger->info('plugin_basename = ' . $this->_plugin_basename);
         $this->_logger->info('plugin_dir_name = ' . $this->_plugin_dir_name);
     }
     // Hook to plugin activation
     register_activation_hook($this->_plugin_main_file_path, array(&$this, '_activate_plugin_event'));
     // Hook to plugin uninstall.
     register_uninstall_hook($this->_plugin_main_file_path, array('Freemius', '_uninstall_plugin'));
     $this->_load_account();
 }
开发者ID:AlexOreshkevich,项目名称:velomode.by,代码行数:27,代码来源:class-freemius.php

示例6: __toString

 /**
  * Print a warning, as a call to this function means that $SIMPLESAML_INCPREFIX is referenced.
  *
  * @return A blank string.
  */
 function __toString()
 {
     $backtrace = debug_backtrace();
     $where = $backtrace[0]['file'] . ':' . $backtrace[0]['line'];
     error_log('Deprecated $SIMPLESAML_INCPREFIX still in use at ' . $where . '. The simpleSAMLphp library now uses an autoloader.');
     return '';
 }
开发者ID:williamamed,项目名称:Raptor2,代码行数:12,代码来源:_include.php

示例7: doWrite

 /**
  * Write a message to the log.
  *
  * @param array $event log data event
  */
 protected function doWrite(array $event)
 {
     $priority = $this->priorityMap[$event['priority']];
     $extra = $event['extra'];
     if ($extra instanceof Traversable) {
         $extra = iterator_to_array($extra);
     } elseif (!is_array($extra)) {
         $extra = [];
     }
     if ($this->contextContainsException($extra)) {
         /** @var \Throwable $exception */
         $exception = $extra['exception'];
         unset($extra['exception']);
         if ($event['message'] !== $exception->getMessage()) {
             $exception = new ContextException($event['message'], $exception->getCode(), $exception);
         }
         $this->client->getRaven()->captureException($exception, ['extra' => $this->sanitizeContextData($extra), 'level' => $priority]);
         return;
     }
     $stack = isset($extra['stack']) && is_array($extra['stack']) ? $extra['stack'] : null;
     if (!$stack) {
         $stack = $this->cleanBacktrace(debug_backtrace());
         if (!count($stack)) {
             $stack = false;
         }
     }
     $this->client->getRaven()->captureMessage($event['message'], $this->sanitizeContextData($extra), $priority, $stack);
 }
开发者ID:facile-it,项目名称:sentry-module,代码行数:33,代码来源:Sentry.php

示例8: query

 public function query($sql)
 {
     if ($this->link) {
         $resource = mysql_query($sql, $this->link);
         if ($resource) {
             if (is_resource($resource)) {
                 $i = 0;
                 $data = array();
                 while ($result = mysql_fetch_assoc($resource)) {
                     $data[$i] = $result;
                     $i++;
                 }
                 mysql_free_result($resource);
                 $query = new \stdClass();
                 $query->row = isset($data[0]) ? $data[0] : array();
                 $query->rows = $data;
                 $query->num_rows = $i;
                 unset($data);
                 return $query;
             } else {
                 return true;
             }
         } else {
             $trace = debug_backtrace();
             trigger_error('Error: ' . mysql_error($this->link) . '<br />Error No: ' . mysql_errno($this->link) . '<br /> Error in: <b>' . $trace[1]['file'] . '</b> line <b>' . $trace[1]['line'] . '</b><br />' . $sql);
         }
     }
 }
开发者ID:honeynatividad,项目名称:mircatu,代码行数:28,代码来源:mysql.php

示例9: check

 /**
  * A helper method to assert "Running" properties
  *
  * @param bool $isScheduledMaintenanceRunning
  * @param bool $isAutoMaintenanceRunning
  */
 function check($isScheduledMaintenanceRunning, $isAutoMaintenanceRunning)
 {
     $aBt = debug_backtrace();
     $oMaintStatus = $this->getInstance();
     $this->assertEqual($oMaintStatus->isScheduledMaintenanceRunning, (bool) $isScheduledMaintenanceRunning, ($isScheduledMaintenanceRunning ? 'True' : 'False') . " was expected for scheduled mainteanance on line {$aBt[0]['line']}");
     $this->assertEqual($oMaintStatus->isAutoMaintenanceRunning, (bool) $isAutoMaintenanceRunning, ($isAutoMaintenanceRunning ? 'True' : 'False') . " was expected for automatic mainteanance on line {$aBt[0]['line']}");
 }
开发者ID:hostinger,项目名称:revive-adserver,代码行数:13,代码来源:Status.mtc.test.php

示例10: halt

/**
 * 错误输出
 * @param mixed $error 错误
 * @return void
 */
function halt($error)
{
    $e = array();
    if (APP_DEBUG) {
        //调试模式下输出错误信息
        if (!is_array($error)) {
            $trace = debug_backtrace();
            $e['message'] = $error;
            $e['file'] = $trace[0]['file'];
            $e['line'] = $trace[0]['line'];
            ob_start();
            debug_print_backtrace();
            $e['trace'] = ob_get_clean();
        } else {
            $e = $error;
        }
    } else {
        //否则定向到错误页面
        $error_page = C('ERROR_PAGE');
        if (!empty($error_page)) {
            redirect($error_page);
        } else {
            if (C('SHOW_ERROR_MSG')) {
                $e['message'] = is_array($error) ? $error['message'] : $error;
            } else {
                $e['message'] = C('ERROR_MESSAGE');
            }
        }
    }
    // 包含异常页面模板
    include C('TMPL_EXCEPTION_FILE');
    exit;
}
开发者ID:omusico,项目名称:MRFOS,代码行数:38,代码来源:functions.php

示例11: mpr

/**
 * My print_r - debug function
 * @author Oliwier Ptak (https://github.com/oliwierptak)
 *
 * Usage example:
 * mpr($mixed);
 * mpr($mixed,1); <- stop execution of the script
 * mpr($mixed,1,1); <- stop execution and show backtrace
 */
function mpr($val, $die = false, $showTrace = false)
{
    if (!headers_sent()) {
        header("content-type: text/plain");
    }
    echo '--MPR--';
    if (is_array($val) || is_object($val)) {
        print_r($val);
        if (is_array($val)) {
            reset($val);
        }
    } else {
        var_dump($val);
    }
    if ($showTrace || $die) {
        $trace = debug_backtrace();
        echo "--\n";
        echo sprintf("Who called me: %s line %s", $trace[0]['file'], $trace[0]['line']);
        if ($showTrace) {
            echo "\nTrace:";
            for ($i = 1; $i <= 100; $i++) {
                if (!isset($trace[$i])) {
                    break;
                }
                echo sprintf("\n%s line %s", $trace[$i]['file'], $trace[$i]['line']);
            }
        }
    }
    echo "\n";
    if ($die) {
        die;
    }
}
开发者ID:romannowicki,项目名称:mpr,代码行数:42,代码来源:mpr.php

示例12: pa

/**
 * output dump of vixed variable. If second arfument is true then do exit of script execution
 *
 * @param mixed $mixed
 * @param bool $stop
 */
function pa($mixed, $stop = false)
{
    $ar = debug_backtrace();
    $key = pathinfo($ar[0]['file']);
    $key = $key['basename'] . ':' . $ar[0]['line'];
    $GLOBALS['print_r_view'][$key][] = $mixed;
    if ($stop > 0) {
        $str = '';
        foreach ($GLOBALS['print_r_view'] as $line => $values) {
            foreach ($values as $key => $value) {
                $temp_ar = array($line => $value);
                $tag = 'pre';
                if (defined('SITE_WAP_MODE') && SITE_WAP_MODE) {
                    $tag = 'wml';
                }
                $str .= '<' . $tag . '>' . htmlspecialchars(print_r($temp_ar, 1)) . '</' . $tag . '>';
            }
        }
        if ($stop == 1) {
            echo $str;
            exit;
        }
        if ($stop == 2) {
            return $str;
        }
    }
}
开发者ID:boozzywoozzy,项目名称:tvoya-peremoga,代码行数:33,代码来源:pa.php

示例13: log

 public function log($data)
 {
     if ($this->config->get('pp_login_debug')) {
         $backtrace = debug_backtrace();
         $this->log->write('Log In with PayPal debug (' . $backtrace[1]['class'] . '::' . $backtrace[1]['function'] . ') - ' . $data);
     }
 }
开发者ID:TimeCheer,项目名称:opencart,代码行数:7,代码来源:pp_login.php

示例14: handleError

 /**
  *
  * @param int $errno        	
  * @param string $errstr        	
  * @param string $errfile        	
  * @param int $errline        	
  * @throws PHPUnit_Framework_Error
  */
 public static function handleError($errno, $errstr, $errfile, $errline)
 {
     if (!($errno & error_reporting())) {
         return false;
     }
     self::$errorStack[] = array($errno, $errstr, $errfile, $errline);
     $trace = debug_backtrace(false);
     array_shift($trace);
     foreach ($trace as $frame) {
         if ($frame['function'] == '__toString') {
             return false;
         }
     }
     if ($errno == E_NOTICE || $errno == E_USER_NOTICE || $errno == E_STRICT) {
         if (PHPUnit_Framework_Error_Notice::$enabled !== true) {
             return false;
         }
         $exception = 'PHPUnit_Framework_Error_Notice';
     } elseif ($errno == E_WARNING || $errno == E_USER_WARNING) {
         if (PHPUnit_Framework_Error_Warning::$enabled !== true) {
             return false;
         }
         $exception = 'PHPUnit_Framework_Error_Warning';
     } elseif ($errno == E_DEPRECATED || $errno == E_USER_DEPRECATED) {
         if (PHPUnit_Framework_Error_Deprecated::$enabled !== true) {
             return false;
         }
         $exception = 'PHPUnit_Framework_Error_Deprecated';
     } else {
         $exception = 'PHPUnit_Framework_Error';
     }
     throw new $exception($errstr, $errno, $errfile, $errline);
 }
开发者ID:ngitimfoyo,项目名称:Nyari-AppPHP,代码行数:41,代码来源:ErrorHandler.php

示例15: test

function test($b)
{
    if (!$b) {
        $bt = debug_backtrace();
        die("\ntest failed in " . $bt[0]["file"] . " line " . $bt[0]["line"] . "\n");
    }
}
开发者ID:oceanwavechina,项目名称:ice,代码行数:7,代码来源:Client.php


注:本文中的debug_backtrace函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。