<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Steve&#039;s Blog &#187; solar</title>
	<atom:link href="http://crindigo.com/blog/tag/solar/feed/" rel="self" type="application/rss+xml" />
	<link>http://crindigo.com/blog</link>
	<description>Escapades of a web programmer</description>
	<lastBuildDate>Sun, 18 Sep 2011 04:40:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4-alpha-19719</generator>
		<item>
		<title>Wildfire Log Adapter for Solar</title>
		<link>http://crindigo.com/blog/2010/05/wildfire-log-adapter-for-solar/</link>
		<comments>http://crindigo.com/blog/2010/05/wildfire-log-adapter-for-solar/#comments</comments>
		<pubDate>Sat, 29 May 2010 05:25:59 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[crindigan]]></category>
		<category><![CDATA[solar]]></category>

		<guid isPermaLink="false">http://crindigo.com/blog/?p=74</guid>
		<description><![CDATA[While doing some more development for Crindigan, I figured I should be looking for a better way to show debug information than putting it in the page footer, so I looked at FirePHP. Unfortunately the Firephp log adapter in Solar &#8230; <a href="http://crindigo.com/blog/2010/05/wildfire-log-adapter-for-solar/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>While doing some more development for Crindigan, I figured I should be looking for a better way to show debug information than putting it in the page footer, so I looked at FirePHP. Unfortunately the Firephp log adapter in <a href="http://solarphp.com/">Solar</a> was out of date, so I wrote a quick adapter that uses the newer Wildfire protocol.</p>
<pre class="brush: php; title: ; notranslate">
/**
 * Log adapter that works with the latest FirePHP version
 * (probably not FireConsole though, whenever it's released).
 *
 * @package Crindigan
 * @author Steven Harris
 * @license http://opensource.org/licenses/bsd-license.php BSD
 * @version $Id$
 */
class Rpg_Log_Adapter_Wildfire extends Solar_Log_Adapter {

    /**
     * Default configuration values.
     *
     * @config string|array events The event types this instance
     *   should recognize; a comma-separated string of events, or
     *   a sequential array.  Default is all events ('*').
     *
     * @config dependency response A Solar_Http_Response dependency injection.
     *
     * @var array
     *
     */
    protected $_Rpg_Log_Adapter_Wildfire = array(
        'events'   =&gt; '*',
        'response' =&gt; 'response',
    );

    /**
     * The Solar_Http_Response where headers will be sent.
     *
     * @var Solar_Http_Response
     */
    protected $_response;

    /**
     * The Solar_Json instance used to encode JSON for Wildfire.
     *
     * @var Solar_Json
     */
    protected $_json;

    /**
     * Wildfire header index to keep headers in sequential order.
     *
     * @var int
     */
    protected $_index = 0;

    /**
     * Post-construction tasks. Sets up the response, JSON, and default Wildfire headers.
     */
    protected function _postConstruct() {
        parent::_postConstruct();

        $this-&gt;_response = Solar::dependency('Solar_Http_Response', $this-&gt;_config['response']);

        $this-&gt;_json = Solar::factory('Solar_Json');

		$this-&gt;_response-&gt;setHeader('X-Wf-Protocol-1', 'http://meta.wildfirehq.org/Protocol/JsonStream/0.2');
        $this-&gt;_response-&gt;setHeader('X-Wf-1-Plugin-1', 'http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.3');
        $this-&gt;_response-&gt;setHeader('X-Wf-1-Structure-1', 'http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1');
    }

    /**
     * Writes the log message to FirePHP.
     *
     * @param  string $class Class name.
     * @param  string $event Event name.
     * @param  mixed  $descr Log data. Any data type should work, assuming it can be encoded as JSON.
     * @return bool Always true.
     */
    protected function _save($class, $event, $descr) {
    	$meta = array();
    	$meta['Type']  = 'LOG';
    	$meta['Label'] = &quot;$class-$event&quot;;

    	$data = $this-&gt;_json-&gt;encode(array($meta, $descr));
    	$len  = strlen($data);

		if ( strlen($data) &lt;= 4990 ) {
			$this-&gt;_index++;
			$this-&gt;_response-&gt;setHeader(&quot;X-Wf-1-1-1-{$this-&gt;_index}&quot;, &quot;$len|$data|&quot;);
		} else {
			$chunks = chunk_split($data, 4990, &quot;\n&quot;);
			$parts = explode(&quot;\n&quot;, $chunks);
            $num_parts = count($parts);
            for ( $i = 0; $i &lt; $num_parts; $i++ ) {
				$this-&gt;_index++;
				$this-&gt;_response-&gt;setHeader(&quot;X-Wf-1-1-1-{$this-&gt;_index}&quot;,
					($i == 0 ? $len : '') . &quot;|{$parts[$i]}|&quot; . (($i == $num_parts - 1) ? '' : '\\'));
            }
        }

        return true;
    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://crindigo.com/blog/2010/05/wildfire-log-adapter-for-solar/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

