Horde::debug PHP Method

debug() public static method

Debug method. Allows quick shortcut to produce debug output into a temporary file.
public static debug ( mixed $event = null, string $fname = null, boolean $backtrace = true )
$event mixed Item to log.
$fname string Filename to log to. If empty, logs to 'horde_debug.txt' in the PHP temporary directory.
$backtrace boolean Include backtrace information?
    public static function debug($event = null, $fname = null, $backtrace = true)
    {
        if (is_null($fname)) {
            $fname = self::getTempDir() . '/horde_debug.txt';
        }
        try {
            $logger = new Horde_Log_Logger(new Horde_Log_Handler_Stream($fname));
        } catch (Exception $e) {
            return;
        }
        $html_ini = ini_set('html_errors', 'Off');
        self::startBuffer();
        if (!is_null($event)) {
            echo "Variable information:\n";
            var_dump($event);
            echo "\n";
        }
        if (is_resource($event)) {
            echo "Stream contents:\n";
            rewind($event);
            fpassthru($event);
            echo "\n";
        }
        if ($backtrace) {
            echo "Backtrace:\n";
            echo strval(new Horde_Support_Backtrace());
        }
        $logger->log(self::endBuffer(), Horde_Log::DEBUG);
        ini_set('html_errors', $html_ini);
    }

Usage Example

Beispiel #1
0
 /**
  * Updates an existing event in the backend.
  *
  * @param Kronolith_Event $event  The event to save.
  *
  * @return string  The event id.
  * @throws Horde_Mime_Exception
  * @throws Kronolith_Exception
  */
 protected function _updateEvent(Kronolith_Event $event)
 {
     $response = $this->_saveEvent($event);
     if (!in_array($response['statusCode'], array(200, 204))) {
         // To find out if $response still contains the final URL after the refactoring
         Horde::debug($response);
         Horde::log(sprintf('Failed to update event on remote calendar: url = "%s", status = %s', '', $response['body']), 'INFO');
         throw new Kronolith_Exception(_("The event could not be updated on the remote server."));
     }
     return $event->id;
 }