示例#1
0
 public function myCallee()
 {
     printf("%s", xdebug_call_class());
     printf("::%s", xdebug_call_function());
     printf(" in %s", xdebug_call_file());
     printf(":%s\n", xdebug_call_line());
 }
示例#2
0
 /**
  * Ajoute un message à la pile.
  *
  * @param array $aParams
  * @return void
  */
 public function addMessage($aParams)
 {
     if (empty($aParams['style'])) {
         $aParams['style'] = 'info';
     }
     $aCompleteBacktrace = debug_backtrace();
     if (!empty($aCompleteBacktrace)) {
         $aParams['backtrace'] = $this->get_debug_print_backtrace(3);
     }
     if (OKT_XDEBUG) {
         if (empty($aParams['file'])) {
             $aParams['file'] = xdebug_call_file();
         }
         if (empty($aParams['line'])) {
             $aParams['line'] = xdebug_call_line();
         }
         $aParams['class'] = xdebug_call_class();
         $aParams['function'] = xdebug_call_function();
     } else {
         $aTrace = next($aCompleteBacktrace);
         if (empty($aParams['file'])) {
             $aParams['file'] = isset($aTrace['file']) ? $aTrace['file'] : '';
         }
         if (empty($aParams['line'])) {
             $aParams['line'] = isset($aTrace['line']) ? $aTrace['line'] : '';
         }
         $aParams['class'] = isset($aTrace['class']) ? $aTrace['class'] : '';
         $aParams['function'] = isset($aTrace['function']) ? $aTrace['function'] : '';
     }
     $this->aStack[] = $aParams;
 }
 function foo($a)
 {
     echo '<br>Class Name : ' . xdebug_call_class() . '<br>';
     //To Display the Class name.
     echo 'Function Name : ' . xdebug_call_function() . '<br>';
     //To Display the Function name.
     echo 'Line : ' . xdebug_call_line() . '<br>';
     //To Display the Function name.
     return $a + 1;
 }
示例#4
0
 /**
  * @param mixed $var
  */
 function appendLog($var)
 {
     if (extension_loaded('xdebug')) {
         $fullFileName = xdebug_call_file();
         $referenceName = substr($fullFileName, strlen(CONFIG_DIR) + 1);
         dump(sprintf('%s:%d %s', $referenceName, xdebug_call_line(), xdebug_call_function()));
     }
     foreach (func_get_args() as $var) {
         VarDumper::dump($var);
     }
 }
示例#5
0
 public function get($id)
 {
     try {
         return parent::offsetGet($id);
     } catch (\Exception $e) {
         if (extension_loaded('xdebug')) {
             throw new DiException(sprintf('Service error "%s" in file "%s" on line %d >> "%s".', $id, xdebug_call_file(), xdebug_call_line(), $e->getMessage()));
         } else {
             throw new DiException(sprintf('Service error "%s" >> "%s"', $id, $e->getMessage()));
         }
     }
 }
示例#6
0
function fix_string($a)
{
    echo "Called @ " . xdebug_call_file() . ":" . xdebug_call_line() . " from " . xdebug_call_function();
}
 /**
  * Add log message (time, memory, message, call, file_line) to _log.
  * Use Profile::traceLast() for $bt.
  *
  * @param string $msg (default = '')
  */
 public function log($msg = '')
 {
     $ts = microtime(true);
     $mem = memory_get_usage();
     if ($mem > $this->_xlog['maxmem']) {
         $this->_xlog['maxmem'] = $mem;
     }
     if ($mem < $this->_xlog['minmem']) {
         $this->_xlog['minmem'] = $mem;
     }
     $log = array('call' => '', 'file_line' => '');
     $log['time'] = $ts - $this->_xlog['time'];
     $log['memory'] = $mem - $this->_xlog['memory'];
     $log['message'] = $msg;
     if ($this->_xdebug_on) {
         $class = xdebug_call_class();
         $func = xdebug_call_function();
         $log['call'] = $class ? $class . '::' . $func : $func;
         $log['file_line'] = basename(xdebug_call_file()) . ':' . xdebug_call_line();
     }
     array_push($this->_log, $log);
     $this->_xlog['time'] = $ts;
     $this->_xlog['memory'] = $mem;
 }
示例#8
0
文件: XDebug.php 项目: ksst/kf
 public static function showCallStack()
 {
     echo 'CallStack - File: ' . xdebug_call_file();
     echo '<br />Class: ' . xdebug_call_class();
     echo '<br />Function: ' . xdebug_call_function();
     echo '<br />Line: ' . xdebug_call_line();
     echo '<br />Depth of Stacks: ' . xdebug_get_stack_depth();
     echo '<br />Content of Stack: ' . xdebug_var_dump(xdebug_get_function_stack());
 }
示例#9
0
/**
 *	Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remontee des bugs.
 *	On doit appeler cette fonction quand une erreur technique bloquante est rencontree.
 *	Toutefois, il faut essayer de ne l'appeler qu'au sein de pages php, les classes devant
 *	renvoyer leur erreur par l'intermediaire de leur propriete "error".
 *	@param      db      	Database handler
 *	@param      error		String or array of errors strings to show
 *  @see        dol_htmloutput_errors
 */
function dol_print_error($db = '', $error = '')
{
    global $conf, $langs, $argv;
    global $dolibarr_main_prod;
    $out = '';
    $syslog = '';
    // Si erreur intervenue avant chargement langue
    if (!$langs) {
        require_once DOL_DOCUMENT_ROOT . "/core/class/translate.class.php";
        $langs = new Translate("", $conf);
        $langs->load("main");
    }
    $langs->load("main");
    $langs->load("errors");
    if ($_SERVER['DOCUMENT_ROOT']) {
        $out .= $langs->trans("DolibarrHasDetectedError") . ".<br>\n";
        if (!empty($conf->global->MAIN_FEATURES_LEVEL)) {
            $out .= "You use an experimental level of features, so please do NOT report any bugs, anywhere, until going back to MAIN_FEATURES_LEVEL = 0.<br>\n";
        }
        $out .= $langs->trans("InformationToHelpDiagnose") . ":<br>\n";
        $out .= "<b>" . $langs->trans("Date") . ":</b> " . dol_print_date(time(), 'dayhourlog') . "<br>\n";
        $out .= "<b>" . $langs->trans("Dolibarr") . ":</b> " . DOL_VERSION . "<br>\n";
        if (isset($conf->global->MAIN_FEATURES_LEVEL)) {
            $out .= "<b>" . $langs->trans("LevelOfFeature") . ":</b> " . $conf->global->MAIN_FEATURES_LEVEL . "<br>\n";
        }
        if (function_exists("phpversion")) {
            $out .= "<b>" . $langs->trans("PHP") . ":</b> " . phpversion() . "<br>\n";
            //phpinfo();       // This is to show location of php.ini file
        }
        $out .= "<b>" . $langs->trans("Server") . ":</b> " . $_SERVER["SERVER_SOFTWARE"] . "<br>\n";
        $out .= "<br>\n";
        $out .= "<b>" . $langs->trans("RequestedUrl") . ":</b> " . $_SERVER["REQUEST_URI"] . "<br>\n";
        $out .= "<b>" . $langs->trans("Referer") . ":</b> " . (isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : '') . "<br>\n";
        $out .= "<b>" . $langs->trans("MenuManager") . ":</b> " . $conf->top_menu . "<br>\n";
        $out .= "<br>\n";
        $syslog .= "url=" . $_SERVER["REQUEST_URI"];
        $syslog .= ", query_string=" . $_SERVER["QUERY_STRING"];
    } else {
        $out .= '> ' . $langs->transnoentities("ErrorInternalErrorDetected") . ":\n" . $argv[0] . "\n";
        $syslog .= "pid=" . getmypid();
    }
    if (is_object($db)) {
        if ($_SERVER['DOCUMENT_ROOT']) {
            $out .= "<b>" . $langs->trans("DatabaseTypeManager") . ":</b> " . $db->type . "<br>\n";
            $out .= "<b>" . $langs->trans("RequestLastAccessInError") . ":</b> " . ($db->lastqueryerror() ? $db->lastqueryerror() : $langs->trans("ErrorNoRequestInError")) . "<br>\n";
            $out .= "<b>" . $langs->trans("ReturnCodeLastAccessInError") . ":</b> " . ($db->lasterrno() ? $db->lasterrno() : $langs->trans("ErrorNoRequestInError")) . "<br>\n";
            $out .= "<b>" . $langs->trans("InformationLastAccessInError") . ":</b> " . ($db->lasterror() ? $db->lasterror() : $langs->trans("ErrorNoRequestInError")) . "<br>\n";
            $out .= "<br>\n";
        } else {
            $out .= '> ' . $langs->transnoentities("DatabaseTypeManager") . ":\n" . $db->type . "\n";
            $out .= '> ' . $langs->transnoentities("RequestLastAccessInError") . ":\n" . ($db->lastqueryerror() ? $db->lastqueryerror() : $langs->trans("ErrorNoRequestInError")) . "\n";
            $out .= '> ' . $langs->transnoentities("ReturnCodeLastAccessInError") . ":\n" . ($db->lasterrno() ? $db->lasterrno() : $langs->trans("ErrorNoRequestInError")) . "\n";
            $out .= '> ' . $langs->transnoentities("InformationLastAccessInError") . ":\n" . ($db->lasterror() ? $db->lasterror() : $langs->trans("ErrorNoRequestInError")) . "\n";
        }
        $syslog .= ", sql=" . $db->lastquery();
        $syslog .= ", db_error=" . $db->lasterror();
    }
    if ($error) {
        $langs->load("errors");
        if (is_array($error)) {
            $errors = $error;
        } else {
            $errors = array($error);
        }
        foreach ($errors as $msg) {
            $msg = $langs->trans($msg);
            if ($_SERVER['DOCUMENT_ROOT']) {
                $out .= "<b>" . $langs->trans("Message") . ":</b> " . $msg . "<br>\n";
            } else {
                $out .= '> ' . $langs->transnoentities("Message") . ":\n" . $msg . "\n";
            }
            $syslog .= ", msg=" . $msg;
        }
    }
    if (empty($dolibarr_main_prod) && $_SERVER['DOCUMENT_ROOT'] && function_exists('xdebug_call_file')) {
        xdebug_print_function_stack();
        $out .= '<b>XDebug informations:</b>' . "<br>\n";
        $out .= 'File: ' . xdebug_call_file() . "<br>\n";
        $out .= 'Line: ' . xdebug_call_line() . "<br>\n";
        $out .= 'Function: ' . xdebug_call_function() . "<br>\n";
        $out .= "<br>\n";
    }
    if (empty($dolibarr_main_prod)) {
        print $out;
    } else {
        define("MAIN_CORE_ERROR", 1);
    }
    //else print 'Sorry, an error occured but the parameter $dolibarr_main_prod is defined in conf file so no message is reported to your browser. Please read the log file for error message.';
    dol_syslog("Error " . $syslog, LOG_ERR);
}
示例#10
0
function lm($str, $var_dump = false, $bHavePost = true)
{
    $bHaveXdebug = function_exists('xdebug_call_line');
    $sShortDate = date('Y-m-d');
    $sFilename = ROOT . "/app/tmp/logs/{$sShortDate}";
    $date = date("d/m/Y H:i:s");
    $sOut = "========================= {$date} ========================= \n";
    if ($bHaveXdebug) {
        $sOut .= "LINE: " . xdebug_call_line() . "\n";
        $sOut .= "FROM: " . xdebug_call_file() . "\n";
        $sOut .= "FUNC: " . xdebug_call_function() . "\n";
    }
    if ($bHavePost) {
        $sOut .= "POST: " . print_r($_POST, true) . "\n";
    }
    $sOut .= "******************************************************** \n";
    if ($var_dump) {
        $sOut .= var_export($str, true);
    } else {
        if (is_array($str)) {
            $sOut .= print_r($str, true);
        } elseif (is_object($str)) {
            $sOut .= print_r($str, true);
        } else {
            $sOut .= ">> {$str}\n";
        }
    }
    //$sOut = print_r(debug_backtrace(), true);
    if ($bHaveXdebug) {
        $aStack = xdebug_get_function_stack();
        foreach ($aStack as $aItem) {
            if (isset($aItem['function'])) {
                $sOut .= $aItem['function'];
            }
            $sOut .= " " . $aItem['file'] . ":" . $aItem['line'] . "\n";
        }
    } else {
        $e = new Exception();
        $sOut .= $e->getTraceAsString();
    }
    $sOut .= "=======================================================================\n";
    $sOut .= "=======================================================================\n";
    $sOut .= "=======================================================================\n\n\n";
    $fp = @fopen($sFilename, "a");
    @fwrite($fp, $sOut);
    @fclose($fp);
    @chmod($sFilename, 0666);
}
 public static function error($string)
 {
     $file = Logger::getFile(xdebug_call_file());
     $out = Logger::format("ERROR", $file, xdebug_call_function(), xdebug_call_line(), $string);
     file_put_contents(Config::DEFAULT_LOGGER_DEBUG_FILE, $out, FILE_APPEND);
 }
示例#12
0
function test()
{
    var_dump(xdebug_call_line());
}
示例#13
0
 public static function b($var)
 {
     echo $var, ': ', xdebug_call_class(), '>', xdebug_call_function(), ' @ ', xdebug_call_file(), ':', xdebug_call_line(), "\n";
     c($var + 1);
 }
示例#14
0
 /**
  * This function returns the line number that contains the function/method that called the current function/method.
  * @return int
  */
 public function callLine()
 {
     return xdebug_call_line();
 }
示例#15
0
文件: Debug.php 项目: ngnpope/jerity
 /**
  * Outputs a block containing the data into the document.
  *
  * @param  mixed    $data       The debugging data to output.
  * @param  boolean  $highlight  Whether the data should be highlighted.
  * @param  boolean  $collapsed  Should the debug block be collapsed initially
  *
  * @todo  Tidy this up.
  * @todo  Formatting and highlighting without xdebug.
  */
 public static function out($data, $highlight = true, $collapsed = false)
 {
     if (!self::$enabled) {
         return;
     }
     static $count = 0;
     $id = '__debug' . $count;
     echo PHP_EOL;
     echo '<div id="' . $id . '" style="background: #fed; border: solid 2px #edc; font-size: 12px; margin: 1em; padding: 0.3em; width: auto;">';
     echo '<div style="background: #edc; overflow: hidden; padding: 0.3em;">';
     echo '<span style="font-weight: bold;">Debug</span>';
     echo '<div style="float: right; font-size: 10px;">( ';
     $style = 'cursor: pointer; text-decoration: underline;';
     if (!$highlight) {
         echo '<span style="' . $style . '" onclick="document.getElementById(\'' . $id . '_data\').select();">Select All</span> | ';
     }
     echo '<span style="' . $style . '" onclick="var e = document.getElementById(\'' . $id . '_data\'); if (e.style.display == \'none\') { e.style.display = \'block\'; this.innerHTML = \'Collapse\'; } else { e.style.display = \'none\'; this.innerHTML = \'Expand\'; }">' . ($collapsed ? 'Expand' : 'Collapse') . '</span> | ';
     echo '<span style="' . $style . '" onclick="var e = document.getElementById(\'' . $id . '\'); e.parentNode.removeChild(e);">Remove</span>';
     echo ' )</div>';
     if (extension_loaded('xdebug')) {
         printf('<span style="display: block; margin-top: 0.3em; white-space: nowrap;">%s:%s in %s::%s()</span>', str_replace($_SERVER['DOCUMENT_ROOT'] . '/', '', xdebug_call_file()), xdebug_call_line(), xdebug_call_class(), xdebug_call_function());
     } else {
         # TODO: Formatting and highlighting without xdebug.
     }
     echo '</div>';
     echo '<pre style="background: none; border: none; margin: none; padding: none;">';
     $style = 'background: none; border: none; margin-top: 0.3em; max-height: 150px; width: 100%;';
     if ($collapsed) {
         $style .= ' display: none;';
     }
     if ($highlight) {
         echo '<div id="' . $id . '_data" style="' . $style . ' font-family: monospace; max-height: 150px; overflow: auto; white-space: pre;">';
         # TODO: Need to escape data without clobbering highlight/xdebug modifications.
         var_dump($data);
         echo '</div>';
     } else {
         echo '<textarea cols="80" rows="8" id="' . $id . '_data" style="' . $style . '">';
         ob_start();
         var_dump($data);
         $data = ob_get_clean();
         echo strip_tags($data);
         echo '</textarea>';
     }
     echo '</pre>';
     echo '</div>';
     echo PHP_EOL, PHP_EOL;
     $count++;
 }