/** * Log a message. * * @param array $args */ public function write($args) { unset($args['type']); $filename = null; $linenum = null; if (HTTP::isSent($filename, $linenum)) { trigger_error("Headers already sent in {$filename} on line {$linenum}. Cannot send log data to FirePHP. You must have Output Buffering enabled via ob_start() or output_buffering ini directive.", E_USER_NOTICE); return; } try { if (!self::initConsole()) { return; } $values = array_merge($this->_eventValues->getAll(), isset($type) ? array('type' => $type) : array(), is_array($message) ? $message : array('message' => $message)); if (!isset($this->columns)) { $this->columns = array_combine(array_keys($values), array_map('ucfirst', array_keys(array_change_key_case($values, CASE_LOWER)))); } foreach (array_keys($this->columns) as $col) { $row[] = isset($values[$col]) ? $values[$col] : null; } if ($this->unique_counter == 0) { HTTP::setHeader("X-FirePHP-Data-{$this->unique_base}00000000", "[\"{$this->title}\","); self::sendMessage(json_encode(array_values($this->columns)), $this->unique_base, $this->unique_counter); HTTP::setHeader("X-FirePHP-Data-{$this->unique_base}99999999", "]"); } self::sendMessage(json_encode($row), $this->unique_base, $this->unique_counter); } catch (\Exception $e) { trigger_error("An exception occured while writing a row to a FirePHP table.\n" . (string) $e, E_USER_WARNING); } }
/** * Send variable dump to the client * * @param string $key * @param mixed $variable * @return boolean */ public static function fbDump($key, $variable) { if (!self::detectClientExtension()) { return false; } if ($key == 'FirePHP.Firebug.Console') { $key = "_right_"; } $filename = ''; $linenum = 0; if (HTTP::isSent($filename, $linenum)) { trigger_error("Headers already sent in {$filename} on line {$linenum}. Cannot send log data to FirePHP. You must have Output Buffering enabled via ob_start() or output_buffering ini directive.", E_USER_NOTICE); return false; } HTTP::setHeader('X-FirePHP-Data-100000000001', '{'); HTTP::setHeader('X-FirePHP-Data-200000000001', '"FirePHP.Dump":{'); HTTP::setHeader('X-FirePHP-Data-2' . str_pad(++self::$counter, 11, '0', STR_PAD_LEFT), '"' . $key . '":' . json_encode($variable) . ','); HTTP::setHeader('X-FirePHP-Data-299999999999', '"__SKIP__":"__SKIP__"},'); HTTP::setHeader('X-FirePHP-Data-999999999999', '"__SKIP__":"__SKIP__"}'); return true; }