@@ -1,54 +1,54 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // requireComponent("../functions/array.php"); |
| 3 | 3 | class Debug { |
| 4 | - public static $stack; |
|
| 5 | - private static $initialized = false; |
|
| 6 | - private function __construct() {} |
|
| 7 | - private static function initialize() { |
|
| 8 | - if (self::$initialized) |
|
| 9 | - return; |
|
| 10 | - self::$stack = []; |
|
| 11 | - self::$initialized = true; |
|
| 12 | - } |
|
| 13 | - private static function out( $_object ) { |
|
| 14 | - if(is_object($_object)) { |
|
| 15 | - echo "isObject"; |
|
| 16 | - } else if(is_array($_object)) { |
|
| 17 | - arrayDump($_object, "Debug"); |
|
| 18 | - } else { |
|
| 19 | - echo $_object; |
|
| 20 | - } |
|
| 21 | - } |
|
| 22 | - public static function log( $_object ) { |
|
| 23 | - self::out(["error" => $_object]); |
|
| 24 | - } |
|
| 25 | - public static function logln( $_object ) { |
|
| 26 | - self::log($_object); |
|
| 27 | - self::out("<br>"); |
|
| 28 | - } |
|
| 29 | - public static function logStack( $_object ) { |
|
| 30 | - self::out([ |
|
| 31 | - "position" => self::$stack, |
|
| 32 | - "error" => $_object |
|
| 33 | - ]); |
|
| 34 | - self::out("<br>"); |
|
| 35 | - } |
|
| 36 | - public static function push() { |
|
| 37 | - $debugInfo = debug_backtrace(); |
|
| 38 | - $debugInfo = [ |
|
| 39 | - "file" => $debugInfo[1]["file"], |
|
| 40 | - "line" => $debugInfo[1]["line"], |
|
| 41 | - "function" => $debugInfo[1]["function"], |
|
| 42 | - "class" => $debugInfo[1]["class"] |
|
| 43 | - ]; |
|
| 44 | - self::$stack[] = $debugInfo; |
|
| 45 | - } |
|
| 46 | - public static function pop() { |
|
| 47 | - if(count(self::$stack)>0) |
|
| 48 | - array_shift(self::$stack); |
|
| 49 | - } |
|
| 50 | - public static function emptyStack() { |
|
| 51 | - self::$stack = []; |
|
| 52 | - } |
|
| 4 | + public static $stack; |
|
| 5 | + private static $initialized = false; |
|
| 6 | + private function __construct() {} |
|
| 7 | + private static function initialize() { |
|
| 8 | + if (self::$initialized) |
|
| 9 | + return; |
|
| 10 | + self::$stack = []; |
|
| 11 | + self::$initialized = true; |
|
| 12 | + } |
|
| 13 | + private static function out( $_object ) { |
|
| 14 | + if(is_object($_object)) { |
|
| 15 | + echo "isObject"; |
|
| 16 | + } else if(is_array($_object)) { |
|
| 17 | + arrayDump($_object, "Debug"); |
|
| 18 | + } else { |
|
| 19 | + echo $_object; |
|
| 20 | + } |
|
| 21 | + } |
|
| 22 | + public static function log( $_object ) { |
|
| 23 | + self::out(["error" => $_object]); |
|
| 24 | + } |
|
| 25 | + public static function logln( $_object ) { |
|
| 26 | + self::log($_object); |
|
| 27 | + self::out("<br>"); |
|
| 28 | + } |
|
| 29 | + public static function logStack( $_object ) { |
|
| 30 | + self::out([ |
|
| 31 | + "position" => self::$stack, |
|
| 32 | + "error" => $_object |
|
| 33 | + ]); |
|
| 34 | + self::out("<br>"); |
|
| 35 | + } |
|
| 36 | + public static function push() { |
|
| 37 | + $debugInfo = debug_backtrace(); |
|
| 38 | + $debugInfo = [ |
|
| 39 | + "file" => $debugInfo[1]["file"], |
|
| 40 | + "line" => $debugInfo[1]["line"], |
|
| 41 | + "function" => $debugInfo[1]["function"], |
|
| 42 | + "class" => $debugInfo[1]["class"] |
|
| 43 | + ]; |
|
| 44 | + self::$stack[] = $debugInfo; |
|
| 45 | + } |
|
| 46 | + public static function pop() { |
|
| 47 | + if(count(self::$stack)>0) |
|
| 48 | + array_shift(self::$stack); |
|
| 49 | + } |
|
| 50 | + public static function emptyStack() { |
|
| 51 | + self::$stack = []; |
|
| 52 | + } |
|
| 53 | 53 | } |
| 54 | 54 | ?> |