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


PHP format_backtrace函数代码示例

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


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

示例1: site_error_handler

function site_error_handler($errno, $errstr, $errfile, $errline)
{
    $today = date("D M j G:i:s T Y");
    if (isset($GLOBALS['CONFIG']['error_log']) && is_file($GLOBALS['CONFIG']['error_log']) && is_writeable($GLOBALS['CONFIG']['error_log'])) {
        $error_log_avail = TRUE;
    } else {
        error_log("sure_invoice: Could not write to error log: " . $GLOBALS['CONFIG']['error_log'], 0);
        $error_log_avail = FALSE;
    }
    // Log the error
    if ($error_log_avail && $errno != E_NOTICE) {
        error_log("{$today}: PHP Error ({$errno}): {$errstr} in {$errfile} at {$errline}.\n", 3, $GLOBALS['CONFIG']['error_log']);
    }
    // Email error
    if (isset($GLOBALS['CONFIG']['error_email']) && $errno != E_NOTICE && $errno != E_USER_NOTICE) {
        error_log("{$_SERVER['SERVER_NAME']} Server Error\n\n{$today}: PHP Error ({$errno}): {$errstr} in {$errfile} at {$errline}.\n", 1, $APP_GLOBALS['ERROR_EMAIL']);
    }
    // If it is an error redirect to error page or print message
    if ($errno == E_COMPILE_ERROR || $errno == E_CORE_ERROR || $errno == E_USER_ERROR || $errno == E_ERROR) {
        if ($GLOBALS['CONFIG']['debug']) {
            $error_msg = "<PRE>PHP Error ({$errno}): {$errfile} at {$errline}.\n\n{$errstr}\n\n\n" . format_backtrace(debug_backtrace()) . "\n\n</PRE>";
        } else {
            $error_msg = "We are sorry, an error has occured while processing your request, please try again later.\n" . "The system administrator has been notified of the problem.\n";
        }
        fatal_error($error_msg);
    }
}
开发者ID:nanoprime,项目名称:sureinvoice,代码行数:27,代码来源:common.php

示例2: get_exception_handler

 /**
  * Silent exception handler.
  *
  * @return callable exception handler
  */
 public static function get_exception_handler()
 {
     return function ($ex) {
         $info = get_exception_info($ex);
         $logerrmsg = "enrol_paypal IPN exception handler: " . $info->message;
         if (debugging('', DEBUG_NORMAL)) {
             $logerrmsg .= ' Debug: ' . $info->debuginfo . "\n" . format_backtrace($info->backtrace, true);
         }
         error_log($logerrmsg);
         exit(0);
     };
 }
开发者ID:janeklb,项目名称:moodle,代码行数:17,代码来源:util.php

示例3: mDebug_log

/**
 * mDebug_log
*
* @param mix $mix
* @param string $msg
* @param int $level
* @return boolean
*/
function mDebug_log($mix, $msg = '', $level = DEBUG_NORMAL)
{
    global $USER, $CFG;
    try {
        if (!useMDebug($level)) {
            return false;
        }
        if (is_object($mix) || is_array($mix)) {
            if (is_object($mix)) {
                $info = "Object " . get_class($mix) . " >> ";
            } elseif (is_array($mix)) {
                $info = "Array >> ";
            }
            $print = print_r((array) $mix, true);
            $print = substr($print, strpos($print, '('));
            $info .= $print;
            $info = substr($info, 0, strlen($info) - 1);
        } else {
            $info = gettype($mix) . " >>  {$mix} \n";
        }
        $from = "";
        if ($CFG->mDebugBacktrace === true) {
            $backtrace = debug_backtrace();
            $from = format_backtrace($backtrace, true);
        }
        if (empty($msg)) {
            error_log(time() . ' : ' . $info . ' : ' . $from, 3, $CFG->dataroot . '/mdebug.log');
        } else {
            error_log(time() . ' : ' . $msg . ' : ' . $info . ' : ' . $from, 3, $CFG->dataroot . '/mdebug.log');
        }
        return true;
    } catch (Exception $e) {
        error_log(time() . ' :  FALHA NO DEBUG >> $e : ' . $from, 3, $CFG->dataroot . '/mdebug.log');
        return false;
    }
}
开发者ID:LMSeXT,项目名称:mDebug,代码行数:44,代码来源:config.php

示例4: ttrss_fatal_handler

function ttrss_fatal_handler()
{
    global $logger;
    global $last_query;
    $error = error_get_last();
    if ($error !== NULL) {
        $errno = $error["type"];
        $file = $error["file"];
        $line = $error["line"];
        $errstr = $error["message"];
        if (!$errno) {
            return false;
        }
        $context = format_backtrace(debug_backtrace());
        $file = substr(str_replace(dirname(dirname(__FILE__)), "", $file), 1);
        if ($last_query) {
            $errstr .= " [Last query: {$last_query}]";
        }
        if (class_exists("Logger")) {
            return Logger::get()->log_error($errno, $errstr, $file, $line, $context);
        }
    }
    return false;
}
开发者ID:XelaRellum,项目名称:tt-rss,代码行数:24,代码来源:errorhandler.php

示例5: debugging

/**
 * Standard Debugging Function
 *
 * Returns true if the current site debugging settings are equal or above specified level.
 * If passed a parameter it will emit a debugging notice similar to trigger_error(). The
 * routing of notices is controlled by $CFG->debugdisplay
 * eg use like this:
 *
 * 1)  debugging('a normal debug notice');
 * 2)  debugging('something really picky', DEBUG_ALL);
 * 3)  debugging('annoying debug message only for developers', DEBUG_DEVELOPER);
 * 4)  if (debugging()) { perform extra debugging operations (do not use print or echo) }
 *
 * In code blocks controlled by debugging() (such as example 4)
 * any output should be routed via debugging() itself, or the lower-level
 * trigger_error() or error_log(). Using echo or print will break XHTML
 * JS and HTTP headers.
 *
 * It is also possible to define NO_DEBUG_DISPLAY which redirects the message to error_log.
 *
 * @uses DEBUG_NORMAL
 * @param string $message a message to print
 * @param int $level the level at which this debugging statement should show
 * @param array $backtrace use different backtrace
 * @return bool
 */
function debugging($message = '', $level = DEBUG_NORMAL, $backtrace = null)
{
    global $CFG, $USER, $UNITTEST;
    $forcedebug = false;
    if (!empty($CFG->debugusers)) {
        $debugusers = explode(',', $CFG->debugusers);
        $forcedebug = in_array($USER->id, $debugusers);
    }
    if (!$forcedebug and empty($CFG->debug) || $CFG->debug < $level) {
        return false;
    }
    if (!isset($CFG->debugdisplay)) {
        $CFG->debugdisplay = ini_get_bool('display_errors');
    }
    if ($message) {
        if (!$backtrace) {
            $backtrace = debug_backtrace();
        }
        $from = format_backtrace($backtrace, CLI_SCRIPT);
        if (!empty($UNITTEST->running)) {
            // When the unit tests are running, any call to trigger_error
            // is intercepted by the test framework and reported as an exception.
            // Therefore, we cannot use trigger_error during unit tests.
            // At the same time I do not think we should just discard those messages,
            // so displaying them on-screen seems like the only option. (MDL-20398)
            echo '<div class="notifytiny">' . $message . $from . '</div>';
        } else {
            if (NO_DEBUG_DISPLAY) {
                // script does not want any errors or debugging in output,
                // we send the info to error log instead
                error_log('Debugging: ' . $message . $from);
            } else {
                if ($forcedebug or $CFG->debugdisplay) {
                    if (!defined('DEBUGGING_PRINTED')) {
                        define('DEBUGGING_PRINTED', 1);
                        // indicates we have printed something
                    }
                    if (CLI_SCRIPT) {
                        echo "++ {$message} ++\n{$from}";
                    } else {
                        echo '<div class="notifytiny">' . $message . $from . '</div>';
                    }
                } else {
                    trigger_error($message . $from, E_USER_NOTICE);
                }
            }
        }
    }
    return true;
}
开发者ID:hatone,项目名称:moodle,代码行数:76,代码来源:weblib.php

示例6: query_log

 /**
  * This logs the last query based on 'logall', 'logslow' and 'logerrors' options configured via $CFG->dboptions .
  * @param string|bool $error or false if not error
  * @return void
  */
 public function query_log($error = false)
 {
     $logall = !empty($this->dboptions['logall']);
     $logslow = !empty($this->dboptions['logslow']) ? $this->dboptions['logslow'] : false;
     $logerrors = !empty($this->dboptions['logerrors']);
     $iserror = $error !== false;
     $time = $this->query_time();
     // Will be shown or not depending on MDL_PERF values rather than in dboptions['log*].
     $this->queriestime = $this->queriestime + $time;
     if ($logall or $logslow and $logslow < $time + 1.0E-5 or $iserror and $logerrors) {
         $this->loggingquery = true;
         try {
             $backtrace = debug_backtrace();
             if ($backtrace) {
                 //remove query_log()
                 array_shift($backtrace);
             }
             if ($backtrace) {
                 //remove query_end()
                 array_shift($backtrace);
             }
             $log = new stdClass();
             $log->qtype = $this->last_type;
             $log->sqltext = $this->last_sql;
             $log->sqlparams = var_export((array) $this->last_params, true);
             $log->error = (int) $iserror;
             $log->info = $iserror ? $error : null;
             $log->backtrace = format_backtrace($backtrace, true);
             $log->exectime = $time;
             $log->timelogged = time();
             $this->insert_record('log_queries', $log);
         } catch (Exception $ignored) {
         }
         $this->loggingquery = false;
     }
 }
开发者ID:gabrielrosset,项目名称:moodle,代码行数:41,代码来源:moodle_database.php

示例7: ensure_theme_not_set

 protected function ensure_theme_not_set() {
     if (!is_null($this->_theme)) {
         throw new coding_exception('The theme has already been set up for this page ready for output. ' .
                 'Therefore, you can no longer change the theme, or anything that might affect what ' .
                 'the current theme is, for example, the course.',
                 'Stack trace when the theme was set up: ' . format_backtrace($this->_wherethemewasinitialised));
     }
 }
开发者ID:nottmoo,项目名称:moodle,代码行数:8,代码来源:pagelib.php

示例8: fatal_error

    /**
     * Returns a template fragment representing a fatal error.
     *
     * @param string $message The message to output
     * @param string $moreinfourl URL where more info can be found about the error
     * @param string $link Link for the Continue button
     * @param array $backtrace The execution backtrace
     * @param string $debuginfo Debugging information
     * @return string A template fragment for a fatal error
     */
    public function fatal_error($message, $moreinfourl, $link, $backtrace, $debuginfo = null) {
        global $CFG;

        $this->page->set_context(null); // ugly hack - make sure page context is set to something, we do not want bogus warnings here

        $e = new stdClass();
        $e->error      = $message;
        $e->stacktrace = NULL;
        $e->debuginfo  = NULL;
        $e->reproductionlink = NULL;
        if (!empty($CFG->debug) and $CFG->debug >= DEBUG_DEVELOPER) {
            $link = (string) $link;
            if ($link) {
                $e->reproductionlink = $link;
            }
            if (!empty($debuginfo)) {
                $e->debuginfo = $debuginfo;
            }
            if (!empty($backtrace)) {
                $e->stacktrace = format_backtrace($backtrace, true);
            }
        }
        $this->header();
        return json_encode($e);
    }
开发者ID:afgal,项目名称:moodle-1,代码行数:35,代码来源:outputrenderers.php

示例9: dprint

function dprint($file, $line, $level, $msg)
{
    global $dPconfig;
    $max_level = 0;
    $max_level = (int) $dPconfig['debug'];
    $display_debug = isset($dPconfig['display_debug']) ? $dPconfig['display_debug'] : false;
    if ($level <= $max_level) {
        error_log("{$file}({$line}): {$msg}");
        if ($display_debug) {
            echo "{$file}({$line}): {$msg} <br />";
        }
        if ($level == 0 && $max_level > 0 && version_compare(phpversion(), "4.3.0") >= 0) {
            format_backtrace(debug_backtrace(), $file, $line, $msg);
        }
    }
}
开发者ID:n2i,项目名称:xvnkb,代码行数:16,代码来源:main_functions.php

示例10: events_process_queued_handler

/**
 * given a queued handler, call the respective event handler to process the event
 *
 * @access protected To be used from eventslib only
 * @deprecated since Moodle 3.1
 * @param stdClass $qhandler events_queued_handler row from db
 * @return boolean true means event processed, false means retry later, NULL means fatal failure
 */
function events_process_queued_handler($qhandler)
{
    global $DB;
    // get handler
    if (!($handler = $DB->get_record('events_handlers', array('id' => $qhandler->handlerid)))) {
        debugging("Error processing queue handler {$qhandler->id}, missing handler id: {$qhandler->handlerid}");
        //irrecoverable error, remove broken queue handler
        events_dequeue($qhandler);
        return NULL;
    }
    // get event object
    if (!($event = $DB->get_record('events_queue', array('id' => $qhandler->queuedeventid)))) {
        // can't proceed with no event object - might happen when two crons running at the same time
        debugging("Error processing queue handler {$qhandler->id}, missing event id: {$qhandler->queuedeventid}");
        //irrecoverable error, remove broken queue handler
        events_dequeue($qhandler);
        return NULL;
    }
    // call the function specified by the handler
    try {
        $errormessage = 'Unknown error';
        if (events_dispatch($handler, unserialize(base64_decode($event->eventdata)), $errormessage)) {
            //everything ok
            events_dequeue($qhandler);
            return true;
        }
    } catch (Exception $e) {
        // the problem here is that we do not want one broken handler to stop all others,
        // cron handlers are very tricky because the needed data might have been deleted before the cron execution
        $errormessage = "Handler function of component {$handler->component}: {$handler->handlerfunction} threw exception :" . $e->getMessage() . "\n" . format_backtrace($e->getTrace(), true);
        if (!empty($e->debuginfo)) {
            $errormessage .= $e->debuginfo;
        }
    }
    //dispatching failed
    $qh = new stdClass();
    $qh->id = $qhandler->id;
    $qh->errormessage = $errormessage;
    $qh->timemodified = time();
    $qh->status = $qhandler->status + 1;
    $DB->update_record('events_queue_handlers', $qh);
    debugging($errormessage);
    return false;
}
开发者ID:evltuma,项目名称:moodle,代码行数:52,代码来源:deprecatedlib.php

示例11: query_log

    /**
     * Log last database query if requested
     * @param mixed string error or false if not error
     * @return void
     */
    public function query_log($error=false) {
        $logall    = !empty($this->dboptions['logall']);
        $logslow   = !empty($this->dboptions['logslow']) ? $this->dboptions['logslow'] : false;
        $logerrors = !empty($this->dboptions['logerrors']);
        $iserror   = ($error !== false);

        $time = microtime(true) - $this->last_time;

        if ($logall or ($logslow and ($logslow < ($time+0.00001))) or ($iserror and $logerrors)) {
            $this->loggingquery = true;
            try {
                $backtrace = debug_backtrace();
                if ($backtrace) {
                    //remove query_log()
                    array_shift($backtrace);
                }
                if ($backtrace) {
                    //remove query_end()
                    array_shift($backtrace);
                }
                $log = new stdClass();
                $log->qtype      = $this->last_type;
                $log->sqltext    = $this->last_sql;
                $log->sqlparams  = var_export((array)$this->last_params, true);
                $log->error      = (int)$iserror;
                $log->info       = $iserror ? $error : null;
                $log->backtrace  = format_backtrace($backtrace, true);
                $log->exectime   = $time;
                $log->timelogged = time();
                $this->insert_record('log_queries', $log);
            } catch (Exception $ignored) {
            }
            $this->loggingquery = false;
        }
    }
开发者ID:nuckey,项目名称:moodle,代码行数:40,代码来源:moodle_database.php

示例12: lti_log_response

/**
 * Log an LTI response.
 *
 * @param string $responsexml The response XML
 * @param Exception $e If there was an exception, pass that too
 */
function lti_log_response($responsexml, $e = null)
{
    if ($tempdir = make_temp_directory('mod_lti', false)) {
        if ($tempfile = tempnam($tempdir, 'mod_lti_response' . date('YmdHis'))) {
            $content = '';
            if ($e instanceof Exception) {
                $info = get_exception_info($e);
                $content .= "Exception:\n";
                $content .= "Message: {$info->message}\n";
                $content .= "Debug info: {$info->debuginfo}\n";
                $content .= "Backtrace:\n";
                $content .= format_backtrace($info->backtrace, true);
                $content .= "\n";
            }
            $content .= "Response XML:\n";
            $content .= $responsexml;
            file_put_contents($tempfile, $content);
            chmod($tempfile, 0644);
        }
    }
}
开发者ID:reconnectmedia,项目名称:moodle,代码行数:27,代码来源:locallib.php

示例13: get_mailer

    try {
        get_mailer('buffer');
        $task->execute();
        if (isset($predbqueries)) {
            mtrace("... used " . ($DB->perf_get_queries() - $predbqueries) . " dbqueries");
            mtrace("... used " . (microtime(1) - $pretime) . " seconds");
        }
        mtrace("Task completed.");
        \core\task\manager::scheduled_task_complete($task);
        get_mailer('close');
        exit(0);
    } catch (Exception $e) {
        if ($DB->is_transaction_started()) {
            $DB->force_transaction_rollback();
        }
        mtrace("... used " . ($DB->perf_get_queries() - $predbqueries) . " dbqueries");
        mtrace("... used " . (microtime(true) - $pretime) . " seconds");
        mtrace("Task failed: " . $e->getMessage());
        if ($CFG->debugdeveloper) {
            if (!empty($e->debuginfo)) {
                mtrace("Debug info:");
                mtrace($e->debuginfo);
            }
            mtrace("Backtrace:");
            mtrace(format_backtrace($e->getTrace(), true));
        }
        \core\task\manager::scheduled_task_failed($task);
        get_mailer('close');
        exit(1);
    }
}
开发者ID:educakanchay,项目名称:campus,代码行数:31,代码来源:schedule_task.php

示例14: fatal_error

 /**
  * Returns a template fragment representing a fatal error.
  * @param string $message The message to output
  * @param string $moreinfourl URL where more info can be found about the error
  * @param string $link Link for the Continue button
  * @param array $backtrace The execution backtrace
  * @param string $debuginfo Debugging information
  * @param bool $showerrordebugwarning Whether or not to show a debugging warning
  * @return string A template fragment for a fatal error
  */
 public function fatal_error($message, $moreinfourl, $link, $backtrace, $debuginfo = null, $showerrordebugwarning = false)
 {
     $output = "!!! {$message} !!!\n";
     if (debugging('', DEBUG_DEVELOPER)) {
         if (!empty($debuginfo)) {
             $this->notification($debuginfo, 'notifytiny');
         }
         if (!empty($backtrace)) {
             $this->notification('Stack trace: ' . format_backtrace($backtrace, true), 'notifytiny');
         }
     }
 }
开发者ID:ajv,项目名称:Offline-Caching,代码行数:22,代码来源:outputrenderers.php

示例15: __construct

    /**
     * You should not need to call this constructor in your own code. Steps are
     * normally created by {@link question_attempt} methods like
     * {@link question_attempt::process_action()}.
     * @param array $data the submitted data that defines this step.
     * @param int $timestamp the time to record for the action. (If not given, use now.)
     * @param int $userid the user to attribute the aciton to. (If not given, use the current user.)
     * @param int $existingstepid if this step is going to replace an existing step
     *      (for example, during a regrade) this is the id of the previous step we are replacing.
     */
    public function __construct($data = array(), $timecreated = null, $userid = null,
            $existingstepid = null) {
        global $USER;

        if (!is_array($data)) {
            echo format_backtrace(debug_backtrace());
        }
        $this->state = question_state::$unprocessed;
        $this->data = $data;
        if (is_null($timecreated)) {
            $this->timecreated = time();
        } else {
            $this->timecreated = $timecreated;
        }
        if (is_null($userid)) {
            $this->userid = $USER->id;
        } else {
            $this->userid = $userid;
        }

        if (!is_null($existingstepid)) {
            $this->id = $existingstepid;
        }
    }
开发者ID:JP-Git,项目名称:moodle,代码行数:34,代码来源:questionattemptstep.php


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