mirror of
https://github.com/sbrl/Pepperminty-Wiki.git
synced 2024-11-22 16:33:00 +00:00
Update build.
This commit is contained in:
parent
d60928b0ea
commit
fb8bc60c44
1 changed files with 42 additions and 6 deletions
|
@ -765,22 +765,58 @@ function system_extension_mime_type($ext) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a stack trace.
|
* Generates a stack trace.
|
||||||
* @param bool $log_trace Whether to send the stack trace to the error log in addition to returning it.
|
* @param bool $log_trace Whether to send the stack trace to the error log.
|
||||||
* @return string A string prepresentation of a stack trace.
|
* @param bool $full Whether to output a full description of all the variables involved.
|
||||||
|
* @return string A string prepresentation of a stack trace.
|
||||||
*/
|
*/
|
||||||
function stack_trace($log_trace = true)
|
function stack_trace($log_trace = true, $full = false)
|
||||||
{
|
{
|
||||||
$result = "";
|
$result = "";
|
||||||
$stackTrace = debug_backtrace();
|
$stackTrace = debug_backtrace();
|
||||||
$stackHeight = count($stackTrace);
|
$stackHeight = count($stackTrace);
|
||||||
foreach ($stackTrace as $i => $stackEntry)
|
foreach ($stackTrace as $i => $stackEntry)
|
||||||
{
|
{
|
||||||
$result .= "#" . ($stackHeight - $i) . " - " . $stackEntry["file"] . ":" . $stackEntry["line"] . " (" . $stackEntry["function"] . ":" . count($stackEntry["args"]) . ")\n";
|
$result .= "#" . ($stackHeight - $i) . ": ";
|
||||||
|
$result .= (isset($stackEntry["file"]) ? $stackEntry["file"] : "(unknown file)") . ":" . (isset($stackEntry["line"]) ? $stackEntry["line"] : "(unknown line)") . " - ";
|
||||||
|
if(isset($stackEntry["function"]))
|
||||||
|
{
|
||||||
|
$result .= "(calling " . $stackEntry["function"];
|
||||||
|
if(isset($stackEntry["args"]) && count($stackEntry["args"]))
|
||||||
|
{
|
||||||
|
$result .= ": ";
|
||||||
|
$result .= implode(", ", array_map($full ? "var_dump_ret" : "var_dump_short", $stackEntry["args"]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$result .= ")\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if($log_trace)
|
if($log_trace)
|
||||||
error_log($result);
|
error_log($result);
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Calls var_dump() and returns the output.
|
||||||
|
* @param mixed $var The thing to pass to var_dump().
|
||||||
|
* @return string The output captured from var_dump().
|
||||||
|
*/
|
||||||
|
function var_dump_ret($var)
|
||||||
|
{
|
||||||
|
ob_start();
|
||||||
|
var_dump($var);
|
||||||
|
return ob_get_clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calls var_dump(), shortening the output for various types.
|
||||||
|
* @param mixed $var The thing to pass to var_dump().
|
||||||
|
* @return string A shortened version of the var_dump() output.
|
||||||
|
*/
|
||||||
|
function var_dump_short($var)
|
||||||
|
{
|
||||||
|
$result = trim(var_dump_ret($var));
|
||||||
|
if(substr($result, 0, 6) === "object" || substr($result, 0, 5) === "array")
|
||||||
|
{
|
||||||
|
$result = substr($result, 0, strpos($result, " ")) . " { ... }";
|
||||||
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue