Toolbox::backtrace PHP Méthode

backtrace() static public méthode

Generate a Backtrace
static public backtrace ( $log = 'php-errors', $hide = '', array $skip = [] ) : string
$log String log file name (default php-errors) if false, return the strung
$hide String call to hide (but display script/line) (default '')
$skip array Array of call to not display at all
Résultat string if $log is false
    static function backtrace($log = 'php-errors', $hide = '', array $skip = array())
    {
        if (function_exists("debug_backtrace")) {
            $message = "  Backtrace :\n";
            $traces = debug_backtrace();
            foreach ($traces as $trace) {
                $script = (isset($trace["file"]) ? $trace["file"] : "") . ":" . (isset($trace["line"]) ? $trace["line"] : "");
                if (strpos($script, GLPI_ROOT) === 0) {
                    $script = substr($script, strlen(GLPI_ROOT) + 1);
                }
                if (strlen($script) > 50) {
                    $script = "..." . substr($script, -47);
                } else {
                    $script = str_pad($script, 50);
                }
                $call = (isset($trace["class"]) ? $trace["class"] : "") . (isset($trace["type"]) ? $trace["type"] : "") . (isset($trace["function"]) ? $trace["function"] . "()" : "");
                if ($call == $hide) {
                    $call = '';
                }
                if (!in_array($call, $skip)) {
                    $message .= "  {$script} {$call}\n";
                }
            }
        } else {
            $message = "  Script : " . $_SERVER["SCRIPT_FILENAME"] . "\n";
        }
        if ($log) {
            self::logInFile($log, $message, true);
        } else {
            return $message;
        }
    }