mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-22 01:49:08 +01:00
LSlog::get_debug_backtrace_context(): add & arguments
This commit is contained in:
parent
9f2cbeca6f
commit
4c7f6847fd
1 changed files with 14 additions and 5 deletions
|
@ -310,25 +310,34 @@ class LSlog {
|
|||
|
||||
/**
|
||||
* Generate current context backtrace
|
||||
*
|
||||
* @param bool $with_args Add args (optional, default: false)
|
||||
* @param int|null $ignore_last_frames Ignore last frames (optional, default: 1)
|
||||
* @return string Current context backtrace
|
||||
**/
|
||||
public static function get_debug_backtrace_context() {
|
||||
public static function get_debug_backtrace_context($with_args=false, $ignore_last_frames=null) {
|
||||
$traces = debug_backtrace();
|
||||
if (!is_array($traces) || count($traces) < 2)
|
||||
return "unknown context";
|
||||
|
||||
$msg = array();
|
||||
$j=0;
|
||||
for ($i=count($traces)-1; $i >= 1; $i--) {
|
||||
for ($i=count($traces)-1; $i >= (is_int($ignore_last_frames)?$ignore_last_frames:1); $i--) {
|
||||
$j += 1;
|
||||
$trace = array("#$j");
|
||||
if (isset($traces[$i]['file']))
|
||||
$trace[] = $traces[$i]['file'].(isset($traces[$i]['line'])?":".$traces[$i]['line']:"");
|
||||
$args = (
|
||||
$with_args && isset($traces[$i]["args"])?
|
||||
format_callable_args($traces[$i]["args"]):
|
||||
""
|
||||
);
|
||||
if (isset($traces[$i]['class']) && isset($traces[$i]['function']))
|
||||
$trace[] = $traces[$i]['class'] . " " . $traces[$i]['type'] . " " . $traces[$i]['function']. "()";
|
||||
$trace[] = sprintf(
|
||||
"%s %s %s(%s)",
|
||||
$traces[$i]['class'], $traces[$i]['type'], $traces[$i]['function'], $args
|
||||
);
|
||||
elseif (isset($traces[$i]['function']))
|
||||
$trace[] = $traces[$i]['function']. "()";
|
||||
$trace[] = sprintf("%s(%s)", $traces[$i]['function'], $args);
|
||||
$msg[] = implode(" - ", $trace);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue