phpCAS::traceBegin PHP Method

traceBegin() public static method

This method is used to indicate the start of the execution of a function in debug mode.
public static traceBegin ( ) : void
return void
    public static function traceBegin()
    {
        $dbg = debug_backtrace();
        $str = '=> ';
        if (!empty($dbg[1]['class'])) {
            $str .= $dbg[1]['class'] . '::';
        }
        $str .= $dbg[1]['function'] . '(';
        if (is_array($dbg[1]['args'])) {
            foreach ($dbg[1]['args'] as $index => $arg) {
                if ($index != 0) {
                    $str .= ', ';
                }
                if (is_object($arg)) {
                    $str .= get_class($arg);
                } else {
                    $str .= str_replace(array("\r\n", "\n", "\r"), "", var_export($arg, true));
                }
            }
        }
        if (isset($dbg[1]['file'])) {
            $file = basename($dbg[1]['file']);
        } else {
            $file = 'unknown_file';
        }
        if (isset($dbg[1]['line'])) {
            $line = $dbg[1]['line'];
        } else {
            $line = 'unknown_line';
        }
        $str .= ') [' . $file . ':' . $line . ']';
        phpCAS::log($str);
        if (!isset(self::$_PHPCAS_DEBUG['indent'])) {
            self::$_PHPCAS_DEBUG['indent'] = 0;
        } else {
            self::$_PHPCAS_DEBUG['indent']++;
        }
    }

Usage Example

Beispiel #1
0
 /**
  * Send the request and store the results.
  *
  * @return bool true on success, false on failure.
  */
 protected function sendRequest()
 {
     phpCAS::traceBegin();
     /*********************************************************
      * initialize the CURL session
      *********************************************************/
     $ch = $this->_initAndConfigure();
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
     phpCAS::log(var_dump($ch) . ' [' . basename($dbg[0]['file']) . ':' . $dbg[0]['line'] . ']');
     /*********************************************************
      * Perform the query
      *********************************************************/
     $buf = curl_exec($ch);
     if ($buf === false) {
         phpCAS::trace('curl_exec() failed');
         $this->storeErrorMessage('CURL error #' . curl_errno($ch) . ': ' . curl_error($ch));
         $res = false;
     } else {
         $this->storeResponseBody($buf);
         phpCAS::trace("Response Body: \n" . $buf . "\n");
         $res = true;
     }
     // close the CURL session
     curl_close($ch);
     phpCAS::traceEnd($res);
     return $res;
 }
All Usage Examples Of phpCAS::traceBegin