-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebugFunctions.php
97 lines (86 loc) · 2.43 KB
/
debugFunctions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
function cs_debug_backtrace($printItForMe=NULL,$removeHR=NULL) {
$gf = new cs_globalFunctions;
if(is_null($printItForMe)) {
if(defined('DEBUGPRINTOPT')) {
$printItForMe = constant('DEBUGPRINTOPT');
}
elseif(isset($GLOBALS['DEBUGPRINTOPT'])) {
$printItForMe = $GLOBALS['DEBUGPRINTOPT'];
}
}
if(is_null($removeHR)) {
if(defined('DEBUGREMOVEHR')) {
$removeHR = constant('DEBUGREMOVEHR');
}
elseif(isset($GLOBALS['DEBUGREMOVEHR'])) {
$removeHR = $GLOBALS['DEBUGREMOVEHR'];
}
}
// if(function_exists("debug_print_backtrace")) {
// //it's PHP5. use output buffering to capture the data.
// ob_start();
// debug_print_backtrace();
//
// $myData = ob_get_contents();
// ob_end_clean();
// }
// else {
//create our own backtrace data.
$stuff = debug_backtrace();
if(is_array($stuff)) {
$i=0;
foreach($stuff as $num=>$arr) {
if($arr['function'] !== "debug_print_backtrace") {
$fromClass = '';
if(isset($arr['class']) && strlen($arr['class'])) {
$fromClass = $arr['class'] .'::';
}
$args = '';
foreach($arr['args'] as $argData) {
$args = $gf->create_list($args, $gf->truncate_string($gf->debug_print($argData, 0, 1, false), 600), ', ');
}
$fileDebug = "";
if(isset($arr['file'])) {
$fileDebug = " from file <u>". $arr['file'] ."</u>, line #". $arr['line'];
}
$tempArr[$num] = $fromClass . $arr['function'] .'('. $args .')'. $fileDebug;
}
}
array_reverse($tempArr);
$myData = null;
foreach($tempArr as $num=>$func) {
$myData = $gf->create_list($myData, "#". $i ." ". $func, "\n");
$i++;
}
}
else {
//nothing available...
$myData = $stuff;
}
// }
$backTraceData = $gf->debug_print($myData, $printItForMe, $removeHR);
return($backTraceData);
}//end cs_debug_backtrace()
function cs_get_where_called() {
$stuff = debug_backtrace();
// foreach($stuff as $num=>$arr) {
// if($arr['function'] != __FUNCTION__ && $arr['function'] != 'debug_backtrace' && (!is_null($fromMethod) && $arr['function'] != $fromMethod)) {
// #$retval = $arr['function'];
// $fromClass = $arr['class'];
// if(!$fromClass) {
// $fromClass = '**GLOBAL**';
// }
// $retval = $arr['function'] .'{'. $fromClass .'}';
// break;
// }
// }
$myData = $stuff[2];
$fromClass = $myData['class'];
if(!$fromClass) {
$fromClass = '**GLOBAL**';
}
$retval = $fromClass .'::'. $myData['function'];
return($retval);
}
?>