Exemplo n.º 1
0
 /**
  * Returns a stacktrace in the form of a string
  */
 public static function trace_string($trace)
 {
     $string = "";
     // Setup the stack trace
     $string .= Eight_Exception::trace_string_line("Stack trace:");
     $string .= Eight_Exception::trace_string_line("");
     $x = 0;
     foreach (Eight_Exception::trace($trace) as $i => $step) {
         $msg_line = "#" . str_pad($x, 2, "0", STR_PAD_LEFT) . "  ";
         if ($step['file']) {
             $source_id = $error_id . 'source' . $i;
             $msg_line .= Eight_Exception::debug_path($step['file']) . '(' . $step['line'] . "):  ";
         } else {
             $msg_line .= "{" . __('PHP internal call') . "}:  ";
         }
         $msg_line .= $step['function'] . '(';
         $print_able_args = array();
         if ($step['args']) {
             $args_id = $error_id . 'args' . $i;
             foreach ($step['args'] as $arg) {
                 $arg_name = "";
                 if (is_object($arg)) {
                     $arg_name = get_class($arg);
                 } else {
                     if (is_array($arg)) {
                         $arg_name = "Array(" . count($arg) . ")";
                     } else {
                         if (is_null($arg)) {
                             $arg_name = "NULL";
                         } else {
                             if (is_string($arg)) {
                                 $arg_name = $arg;
                             } else {
                                 $arg_name = strval($arg);
                             }
                         }
                     }
                 }
                 $arg_name = preg_replace("#\\s+#", " ", $arg_name);
                 $print_able_args[] = str::limit_chars($arg_name, 50, "");
             }
         }
         $msg_line .= implode(", ", $print_able_args);
         $msg_line .= ")";
         $string .= Eight_Exception::trace_string_line($msg_line);
         $x++;
     }
     return $string;
 }