<?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>Turing tarpit &#187; debugging</title>
	<atom:link href="http://www.turingtarpit.com/tag/debugging/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.turingtarpit.com</link>
	<description>Where everything is possible but nothing of interest is easy –Alan Perlis</description>
	<lastBuildDate>Thu, 11 Mar 2010 02:01:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Wordpress Logger: A plugin that displays log messages to the Safari and Firefox console from PHP</title>
		<link>http://www.turingtarpit.com/2009/05/wordpress-logger-a-plugin-to-display-php-log-messages-in-safari-and-firefox/</link>
		<comments>http://www.turingtarpit.com/2009/05/wordpress-logger-a-plugin-to-display-php-log-messages-in-safari-and-firefox/#comments</comments>
		<pubDate>Tue, 12 May 2009 06:04:05 +0000</pubDate>
		<dc:creator>Chandima Cumaranatunge</dc:creator>
				<category><![CDATA[Plugin]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://www.turingtarpit.com/?p=369</guid>
		<description><![CDATA[This is an essential plugin for developers who are frustrated with debugging plugins and themes with <code>print_r</code> statements. This plugin displays log messages from PHP in the browser console in Safari and Firefox (with firebug). You no longer have to work blind when your templates don't render properly. Just place a log statement and examine the code right on the browser. ]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.turingtarpit.com/wp-content/uploads/2009/05/wplogger_icon.jpg" alt="wplogger_icon" title="wplogger_icon" width="200" height="200" class="alignleft size-full wp-image-390  post-thumb" /><span class="post-tagline">Essential debugging tool for plugin and theme developers.</span></p>
<p>Display log messages from PHP in the browser console in Safari and Firefox (with firebug). You no longer have to use <code>print_r</code> statements from PHP to figure out what is going on in the code. Besides, <code>print_r</code> statements  mess up the DOM and HTML layout. </p>
<p><a href="http://downloads.wordpress.org/plugin/wordpress-logger.zip"><img class="alignnone size-full wp-image-313" title="Download wplogger plugin" src="http://www.turingtarpit.com/wp-content/uploads/2009/03/download2_btn.jpg" alt="Download wplogger plugin" width="130" height="30" /></a></p>
<a name="wptoc_0_0_0"></a><h3>Features</h3>
<ul>
<li>Log debug messages directly from themes and <span>plugins</span>.</li>
<li>Display log messages in the browser console, without muddying up the browser display.</li>
<li>Displays complex structures such as arrays and objects in pretty print.</li>
<li>Shows the line number and file from where the message was logged ( you won&#8217;t lose track of log statements ).</li>
</ul>
<a name="wptoc_0_0_1"></a><h3><span>Screenshots</span></h3>
<div id="attachment_376" class="wp-caption alignnone" style="width: 310px"><a title="Firefox console showing debug messages." rel="shadowbox[browser console]" href="http://www.turingtarpit.com/wp-content/uploads/2009/05/screenshot-1.png"><img class="size-medium wp-image-376" src="http://www.turingtarpit.com/wp-content/uploads/2009/05/screenshot-1-300x153.png" alt="Firefox console showing debug messages." width="300" height="153" /></a><p class="wp-caption-text">Firefox console showing debug messages.</p></div><br />
<div id="attachment_378" class="wp-caption alignnone" style="width: 310px"><a title="Safari console showing debug messages" rel="shadowbox[browser console]" href="http://www.turingtarpit.com/wp-content/uploads/2009/05/screenshot-2.png"><img class="size-medium wp-image-378   " title="Safari console" src="http://www.turingtarpit.com/wp-content/uploads/2009/05/screenshot-2-300x150.png" alt="Safari console showing debug messages" width="300" height="150" /></a><p class="wp-caption-text">Safari console showing debug messages</p></div>
<a name="wptoc_0_0_2"></a><h3><strong>Installation</strong></h3>
<ol>
<li>Verify that you have PHP5, which is required for this <span>plugin</span>.</li>
<li> <span>Download</span> the whole <code>wplogger</code> folder into the <code>/wp-content/plugins/</code> directory.</li>
<li>Activate the <em>plugin</em> through the <em>Plugins</em> menu in WordPress.</li>
</ol>
<a name="wptoc_0_0_3"></a><h3>Requirements</h3>
<ul>
<li>Make sure that your theme template has a footer ( <em>index.php</em> should have a <em>get_footer()</em> function call at the end).</li>
<li>Turn on the console in your browser:
<ul>
<li><strong>Firefox:</strong> The <a title="Firebug home page" href="http://getfirebug.com/" target="_blank">Firebug</a> extension needs to be installed and activated.</li>
<li><strong>Safari:</strong> Show the <em>Error Console</em> from the <em>Debug</em>/<em>Develop</em> menu.<br />
Details on how to enable the <em>Debug</em> menu for Safari on <a href="http://www.macosxhints.com/article.php?story=20030110063041629" target="_blank">OSX</a> and <a href="http://robrohan.com/2007/06/11/enable-debug-mode-on-safari-windows-error/" target="_blank">Windows</a>.</li>
</ul>
</li>
</ul>
<a name="wptoc_0_0_4"></a><h3>Usage</h3>
<p>After activating the <span>plugin</span>, the following PHP function call can log any PHP expression to the console log.</p>
<div>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$wplogger</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">log</span><span style="color: #009900;">&#40;</span> php_expression <span style="color: #009900;">&#91;</span><span style="color: #339933;">,</span> message_type<span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</div>
<div>
<p>The message_type is optional and can be any one of the following constants:</p>
<ul>
<li>WPLOG_ERR</li>
<li>WPLOG_WARNING</li>
<li>WPLOG_INFO</li>
<li>WPLOG_DEBUG</li>
</ul>
</div>
<a name="wptoc_0_0_5"></a><h3>Use cases</h3>
<a name="wptoc_5_1_0"></a><h4>Logging from template files</h4>
<p>This is from inside the loop to display post IDs.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000088;">$wplogger</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">log</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Post ID: '</span><span style="color: #339933;">.</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><strong>Output:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">[Information: from line 20 in file index.php] Post ID: 125
[Information: from line 20 in file index.php] Post ID: 116
[Information: from line 20 in file index.php] Post ID: 65</pre></div></div>

<a name="wptoc_5_1_1"></a><h4>Logging from PHP files</h4>
<p>This is from  <em>functions.php</em> ( always a good idea to check if <code>$wplogger</code> is available ). Note the message type set to <em>warning</em> through the second parameter.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$wplogger</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$wplogger</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">log</span><span style="color: #009900;">&#40;</span> get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'active_plugins'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> WPLOG_WARNING <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><strong>Output:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">[Warning: from line 55 in file functions.&lt;span&gt;php&lt;/span&gt;] array (
	  0 =&gt; 'wplogger/wplogger.php',
	  1 =&gt; '12seconds-widget/12seconds-widget.php',
	  2 =&gt; 'get-the-image/get-the-image.php',
)</pre></div></div>

<a name="wptoc_5_1_2"></a><h4>Logging from <span>plugins</span></h4>
<p><span>This is from inside a <em>plugin</em> function. Note the global statement to get <code>$wplogger</code> into current scope.</span></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wplogger</span><span style="color: #339933;">;</span> <span style="color: #000088;">$wplogger</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">log</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'No images attached to this post'</span><span style="color: #339933;">,</span> WPLOG_ERR <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><strong>Output:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">[Error: from line 206 in file get-the-image.php] No images attached to this post</pre></div></div>

<a name="wptoc_0_0_6"></a><h3>Credits</h3>
<p>Code that forces the wplogger plugin to load first was adapted from the WordPress <a title="FirePHP plugin" href="http://inchoo.net/wordpress/wordpress-firephp-plugin/" target="_blank">FirePHP plugin</a> developed by Ivan Weiller.</p>
<p>This plugin is based on <a title="PEAR Log" href="http://pear.php.net/package/Log" target="_blank">PEAR Log</a>, the logging framework that is part of the PHP PEAR library. Current maintainers Jon Parise, Jan Schneider, and Chuck Hagenbuch. PEAR Log is based on code first developed for the Horde 1.3 framework &#8211; original authors Chuck Hagenbuch, and Jon Parise.</p>
<a name="wptoc_0_0_7"></a><h3>Download Plugin</h3>
<p><a href="http://downloads.wordpress.org/plugin/wordpress-logger.zip"><img class="alignnone size-full wp-image-313" title="Download wplogger plugin" src="http://www.turingtarpit.com/wp-content/uploads/2009/03/download2_btn.jpg" alt="Download wplogger plugin" width="130" height="30" /></a></p>
<a name="wptoc_0_0_8"></a><h3>Feature requests and critiques</h3>
<p>This is the first iteration of the wplogger plugin. Please comment on how you would like to see it improved.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.turingtarpit.com/2009/05/wordpress-logger-a-plugin-to-display-php-log-messages-in-safari-and-firefox/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>PureMVC Console &#8211; Shines a light inside the MVC triad</title>
		<link>http://www.turingtarpit.com/2009/03/puremvc-console-shines-a-light-inside-the-mvc-triad/</link>
		<comments>http://www.turingtarpit.com/2009/03/puremvc-console-shines-a-light-inside-the-mvc-triad/#comments</comments>
		<pubDate>Mon, 02 Mar 2009 22:31:38 +0000</pubDate>
		<dc:creator>Chandima Cumaranatunge</dc:creator>
				<category><![CDATA[Debugging]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[logging]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[PureMVC]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.turingtarpit.com/?p=26</guid>
		<description><![CDATA[I was checking the PureMVC website today and came across PureMVC Console developed by the good folks at Kap Lab. This is an absolutely invaluable tool to figure out in real-time what is going on inside the Flex PureMVC framework in a running application.]]></description>
			<content:encoded><![CDATA[<p>I was checking the <a href="http://puremvc.org/">PureMVC</a> website today and came across <a href="http://lab.kapit.fr/display/puremvcconsole/PureMVC+Console">PureMVC Console</a> developed by the good folks at <a href="http://lab.kapit.fr/display/kaplabhome/Home">Kap Lab</a>. This is an absolutely invaluable tool to figure out in real-time what is going on inside the Flex PureMVC framework in a running application. PureMVC is quite lightweight and is very good at keeping things hidden under the hood. However, during development it is essential to get a snapshot of application state and the sequence of notifications. This is exactly what PureMVC Console does. It provides you with a flashlight to peer into your Notifications, Commands, Mediators and Proxies and track notifications and application flow in response to user gestures and other events.</p>
<div>
<p>For example, if you need to know the state of your <em>value objects</em> at any point, just click on the <em>Proxies</em>tab and select the proxy.</p>
<p><a title="Inspecting the value objects inside the proxies" rel="shadowbox[PureMVC Console]" href="http://www.turingtarpit.com/wp-content/uploads/2009/03/vos.jpg"><img class="alignnone size-medium wp-image-28" title="Inspecting the value objects inside the proxies" src="http://www.turingtarpit.com/wp-content/uploads/2009/03/vos-300x257.jpg" alt="Inspecting the value objects inside the proxies" width="300" height="257" /></a></p>
<p>If you want to check the sequence of actions taking place in your application from startup, just click on the PureMVC flow tab. This is very useful for debugging as it provides a record of the command invocation sequence and will help answer questions like &#8220;why did this command execute before this other one?&#8221;</p>
<p><a title="Inspecting the flow of the application" rel="shadowbox[PureMVC Console]" href="http://www.turingtarpit.com/wp-content/uploads/2009/03/flow1.jpg"><img class="alignnone size-medium wp-image-32" title="Inspecting the flow of the application" src="http://www.turingtarpit.com/wp-content/uploads/2009/03/flow1-300x259.jpg" alt="Inspecting the flow of the application" width="300" height="259" /></a></p>
<p>I am a big fan of the <a href="http://osflash.org/xray">Xray logger</a> developed for Flash AS2 and had to try out this console right away as this is the first console with similar utility for AS3, I integrated the console into the <a href="http://trac.puremvc.org/Demo_AS3_Flex_EmployeeAdmin">Employee Admin demo</a> (developed by Cliff Hall).</p>
<a name="wptoc_0_0_0"></a><h4>Employee Admin Demo with integrated Console</h4>
<p>Click on the button below to open the Employee Admin demo. Make sure that you hit <strong>Ctrl+Alt+F6</strong> to open the console ( <strong>Alt</strong> = <strong>Option</strong> in OSX ).</p>
<p><a href="http://www.turingtarpit.com/wp-content/uploads/2009/03/employeeadmin.swf" target="_blank"><img class="alignnone size-full wp-image-39" title="click_to_open_btn" src="http://www.turingtarpit.com/wp-content/uploads/2009/03/click_to_open_btn.jpg" alt="click_to_open_btn" width="101" height="34" /></a></p>
<a name="wptoc_0_0_1"></a><h4>Integrating the console into the <em>Employee Admin</em> Demo</h4>
<p>The console is very easy to integrate into a new or existing app &#8211; just follow the <a href="http://lab.kapit.fr/display/puremvcconsole/Integration+Guide">integration guide</a>. The ease of integration is a huge plus as it is simply injected before the application is invoked.</p>
<a name="wptoc_1_1_0"></a><h5>1. Add the PureMVC Console SWC into your library</h5>
<p>First drag-and-drop the PureMVC Console swc file into the libs folder in your Flex project. There is a different swc if you are using the multi-core version of PureMVC.</p>
<p><img class="alignnone size-full wp-image-50" title="project_files" src="http://www.turingtarpit.com/wp-content/uploads/2009/03/project_files.jpg" alt="project_files" width="226" height="199" /></p>
<a name="wptoc_1_1_1"></a><h5>2. Add the console component into your application</h5>
<p>For an MXML app, you need to add an additional  <code>xmlns:kapit="fr.kapit.*"</code> name space attribute to the  <code>&lt;mx:Application&gt;</code> tag and then add the  <code>&lt;kapit:PureMVCConsole/&gt;</code> component before the closing <code>&lt;/mx:Application&gt;</code> tag (see <a href="http://lab.kapit.fr/display/puremvcconsole/Integration+Guide">integration guide</a>). I added this to the <code>EmployeeAdmin.mxml</code> file which is the default application for the project.</p>
<a name="wptoc_1_1_2"></a><h5>3. Add a new SwitchFacade parent class for you application facade</h5>
<p>The next step is to create a new <code>SwitchFacade</code> class and modify your application facade so that it inherits from <code>SwitchFacade</code> ( instead of the PureMVC <code>Facade</code> class ). The <code>SwitchFacade</code> class is the same for all apps and can be copied and pasted from the <a href="http://lab.kapit.fr/display/puremvcconsole/Integration+Guide">integration guide</a>. Make sure you create the <code>SwitchFacade</code> class in the same location in the folder hierarchy where you current application facade class resides. You can right click on the enclosing folder (employeeadmin in my case) and create <strong>New &gt; ActionScript Class</strong> and type in <code>SwitchFacade</code> for the class name. Now copy and paste the code.</p>
<p><img class="alignnone size-full wp-image-54" title="project_files2" src="http://www.turingtarpit.com/wp-content/uploads/2009/03/project_files2.jpg" alt="project_files2" width="345" height="415" /></p>
<p>Injecting the  <code>SwitchFacade</code> class allows you to control the integration of the console using compiler directives as opposed to changing code when it comes time to ship the application. <code>SwitchFacade</code> extends the PureMVC <code>Facade</code> class if the <em>CONFIG::release</em> directive is set. Conversely, if the <em>CONFIG::debug</em> directive is set ( and <em>CONFIG::release</em> is unset), <code>SwitchFacade</code> extends  <code>DebugFacade</code> that has all the debug stuff required by the console.</p>
<a name="wptoc_1_1_3"></a><h5>4. Set the compiler directives</h5>
<p>To control which facade gets extended you need to add the <em>CONFIG::release</em> and <em>CONFIG::debug</em> directives in the compiler options. Right click on the <em>Project folder</em> and choose <em>properties</em> from the contextual menu. Now click on <em>Flex Compiler</em> option to add the additional compiler directives in the <em>Additional Compiler Arguments</em> field.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">-define=CONFIG::release,false -define=CONFIG::debug,true</pre></div></div>

<p><a title="Setting compiler options" rel="shadowbox[PureMVC Console]" href="http://www.turingtarpit.com/wp-content/uploads/2009/03/compiler_options.jpg"><img class="alignnone size-medium wp-image-57" title="compiler_options" src="http://www.turingtarpit.com/wp-content/uploads/2009/03/compiler_options-300x240.jpg" alt="compiler_options" width="300" height="240" /></a></p>
<p><a title="Setting compiler options" rel="shadowbox[PureMVC Console]" href="http://www.turingtarpit.com/wp-content/uploads/2009/03/compiler_options.jpg"></a><br />
Reset the directives for the release version.</p>
<p><strong>Recap of cool features:</strong></p>
<ul>
<li>Very easy to integrate into a new or existing app.</li>
<li>Works with the standard version of Flash ( does not need the debugger version ).</li>
<li>Integration is controlled by using compiler options ( just change a compiler option for the release version ).</li>
</ul>
<p>Simple to integrate and keeps out of the way of you doing the job of coding and debugging &#8211; excellent!</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.turingtarpit.com/2009/03/puremvc-console-shines-a-light-inside-the-mvc-triad/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
