<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: jQuery Logging</title>
	<atom:link href="http://ajaxian.com/archives/jquery-logging/feed" rel="self" type="application/rss+xml" />
	<link>http://ajaxian.com/archives/jquery-logging</link>
	<description>Cleaning up the web with Ajax</description>
	<lastBuildDate>Thu, 17 May 2012 07:43:39 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: fmsf</title>
		<link>http://ajaxian.com/archives/jquery-logging/comment-page-1#comment-285979</link>
		<dc:creator>fmsf</dc:creator>
		<pubDate>Tue, 27 Dec 2011 07:19:03 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/archives/jquery-logging#comment-285979</guid>
		<description>Hi! I&#039;ve done this http://www.jquerylog.com which kinda resembles the logging, but I gess it&#039;s easier to use. I got inspired by Dominic&#039;s mini plugin and decided to do a more complete one.Check it out and comment it :)</description>
		<content:encoded><![CDATA[<p>Hi! I&#8217;ve done this <a href="http://www.jquerylog.com" rel="nofollow">http://www.jquerylog.com</a> which kinda resembles the logging, but I gess it&#8217;s easier to use. I got inspired by Dominic&#8217;s mini plugin and decided to do a more complete one.Check it out and comment it :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Christophe Buguet</title>
		<link>http://ajaxian.com/archives/jquery-logging/comment-page-1#comment-257502</link>
		<dc:creator>Christophe Buguet</dc:creator>
		<pubDate>Mon, 22 Oct 2007 10:09:45 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/archives/jquery-logging#comment-257502</guid>
		<description>I wrote a version for YUI. The article is in french, but the code should be readable :
http://www.codingstyle.fr/2007/10/22/rediriger-la-console-de-yahoo-dans-firebug/</description>
		<content:encoded><![CDATA[<p>I wrote a version for YUI. The article is in french, but the code should be readable :<br />
<a href="http://www.codingstyle.fr/2007/10/22/rediriger-la-console-de-yahoo-dans-firebug/" rel="nofollow">http://www.codingstyle.fr/2007/10/22/rediriger-la-console-de-yahoo-dans-firebug/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: EmEhRKay</title>
		<link>http://ajaxian.com/archives/jquery-logging/comment-page-1#comment-257494</link>
		<dc:creator>EmEhRKay</dc:creator>
		<pubDate>Sun, 21 Oct 2007 21:49:34 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/archives/jquery-logging#comment-257494</guid>
		<description>Michael, you are right. And for some reason, this morning, my first example crossed my mind and I did see that it was wrong. 

This may be an easier example while keeping the scope within the namespace:

var test = {
    t: function(){
        console.log(&#039;--&#039;);
        return this;
    },
    log: function(m){
        console.log(m);
        return this;
    }
};

test.t().log(&#039;without a library&#039;).t();</description>
		<content:encoded><![CDATA[<p>Michael, you are right. And for some reason, this morning, my first example crossed my mind and I did see that it was wrong. </p>
<p>This may be an easier example while keeping the scope within the namespace:</p>
<p>var test = {<br />
    t: function(){<br />
        console.log(&#8216;&#8211;&#8217;);<br />
        return this;<br />
    },<br />
    log: function(m){<br />
        console.log(m);<br />
        return this;<br />
    }<br />
};</p>
<p>test.t().log(&#8216;without a library&#8217;).t();</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael Geary</title>
		<link>http://ajaxian.com/archives/jquery-logging/comment-page-1#comment-257475</link>
		<dc:creator>Michael Geary</dc:creator>
		<pubDate>Sat, 20 Oct 2007 20:48:05 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/archives/jquery-logging#comment-257475</guid>
		<description>EmEhRKay, in the code you posted:

&lt;code&gt;
function test(){
console.log(â€™â€”â€™);
return this;
}

function log(msg){
console.log(msg);
return this;
}

test().log(â€™Hey, I am doing this with jQuery!â€™).test();
&lt;/code&gt;

if the code is running at global scope, &quot;this&quot; is the global object, i.e. the window. So there&#039;s no reason to do any chaining in the first place. A bare function call is the same as calling a window method, so the code is equivalent to:

&lt;code&gt;
function test(){
console.log(â€™â€”â€™);
}

function log(msg){
console.log(msg);
}

test();
log(â€™Hey, I am doing this with jQuery!â€™);
test();
&lt;/code&gt;

But your point is well taken that you could add a .log method to any object. For example, here is a log method for strings:

&lt;code&gt;
String.prototype.log = function( format ) {
    window.console &amp;&amp; console.log(
        format &#124;&#124; &#039;String length %i, value &quot;%s&quot;&#039;,
        this.length, this );
    return &#039;&#039;+this;
};

&#039;just testing&#039;.log().slice(5,9).log();
&lt;/code&gt;

If you paste that into the Firebug console (in multiline mode) you will see:

&lt;code&gt;
String length 12, value &quot;just testing&quot;
String length 4, value &quot;test&quot;
&quot;test&quot;
&lt;/code&gt;

Note the use of &quot;return &#039;&#039;+this;&quot; instead of just &quot;return this;&quot; - that causes the function to return a primitive string instead of a string object, which gives less surprising results at least in this test case. (Try changing it to &quot;return this;&quot; and see what Firebug displays.)</description>
		<content:encoded><![CDATA[<p>EmEhRKay, in the code you posted:</p>
<p><code><br />
function test(){<br />
console.log(â€™â€”â€™);<br />
return this;<br />
}</p>
<p>function log(msg){<br />
console.log(msg);<br />
return this;<br />
}</p>
<p>test().log(â€™Hey, I am doing this with jQuery!â€™).test();<br />
</code></p>
<p>if the code is running at global scope, &#8220;this&#8221; is the global object, i.e. the window. So there&#8217;s no reason to do any chaining in the first place. A bare function call is the same as calling a window method, so the code is equivalent to:</p>
<p><code><br />
function test(){<br />
console.log(â€™â€”â€™);<br />
}</p>
<p>function log(msg){<br />
console.log(msg);<br />
}</p>
<p>test();<br />
log(â€™Hey, I am doing this with jQuery!â€™);<br />
test();<br />
</code></p>
<p>But your point is well taken that you could add a .log method to any object. For example, here is a log method for strings:</p>
<p><code><br />
String.prototype.log = function( format ) {<br />
    window.console &amp;&amp; console.log(<br />
        format || 'String length %i, value "%s"',<br />
        this.length, this );<br />
    return ''+this;<br />
};</p>
<p>'just testing'.log().slice(5,9).log();<br />
</code></p>
<p>If you paste that into the Firebug console (in multiline mode) you will see:</p>
<p><code><br />
String length 12, value "just testing"<br />
String length 4, value "test"<br />
"test"<br />
</code></p>
<p>Note the use of &#8220;return &#8221;+this;&#8221; instead of just &#8220;return this;&#8221; &#8211; that causes the function to return a primitive string instead of a string object, which gives less surprising results at least in this test case. (Try changing it to &#8220;return this;&#8221; and see what Firebug displays.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joan Piedra</title>
		<link>http://ajaxian.com/archives/jquery-logging/comment-page-1#comment-257472</link>
		<dc:creator>Joan Piedra</dc:creator>
		<pubDate>Sat, 20 Oct 2007 18:37:51 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/archives/jquery-logging#comment-257472</guid>
		<description>Hey guys,
I agree with Michael, this is such a omg-why-didnt-i-think-of-it-earlier plugin! Take a look at some little enhancements I tried.

http://pastemonkey.org/paste/471a49a0-fc54-4ca8-b8e7-5411404fdb0d</description>
		<content:encoded><![CDATA[<p>Hey guys,<br />
I agree with Michael, this is such a omg-why-didnt-i-think-of-it-earlier plugin! Take a look at some little enhancements I tried.</p>
<p><a href="http://pastemonkey.org/paste/471a49a0-fc54-4ca8-b8e7-5411404fdb0d" rel="nofollow">http://pastemonkey.org/paste/471a49a0-fc54-4ca8-b8e7-5411404fdb0d</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JFR</title>
		<link>http://ajaxian.com/archives/jquery-logging/comment-page-1#comment-257469</link>
		<dc:creator>JFR</dc:creator>
		<pubDate>Sat, 20 Oct 2007 15:24:13 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/archives/jquery-logging#comment-257469</guid>
		<description>Great plugin, and it is working with Companion.JS so you can also log in IE with it ;-)

JFR
http://www.debugbar.com</description>
		<content:encoded><![CDATA[<p>Great plugin, and it is working with Companion.JS so you can also log in IE with it ;-)</p>
<p>JFR<br />
<a href="http://www.debugbar.com" rel="nofollow">http://www.debugbar.com</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JÃ¶rn Zaefferer</title>
		<link>http://ajaxian.com/archives/jquery-logging/comment-page-1#comment-257467</link>
		<dc:creator>JÃ¶rn Zaefferer</dc:creator>
		<pubDate>Sat, 20 Oct 2007 14:19:36 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/archives/jquery-logging#comment-257467</guid>
		<description>I agree with Michael, this is definitely a smack-head snippet, thanks Dominic.

The great thing is that it helps a lot to avoid chaining-breakups for logging purposes. Eg. something like this would be much simpler:

var toLog = $(&quot;.selectotor&quot;);
console.log(toLog);
toLog.doSomething();

Just doing $(&quot;.selector).log().doSomething() is that much simpler. And you can add the check if the console object exists to the log plugin implementation.</description>
		<content:encoded><![CDATA[<p>I agree with Michael, this is definitely a smack-head snippet, thanks Dominic.</p>
<p>The great thing is that it helps a lot to avoid chaining-breakups for logging purposes. Eg. something like this would be much simpler:</p>
<p>var toLog = $(&#8220;.selectotor&#8221;);<br />
console.log(toLog);<br />
toLog.doSomething();</p>
<p>Just doing $(&#8220;.selector).log().doSomething() is that much simpler. And you can add the check if the console object exists to the log plugin implementation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: EmEhRKay</title>
		<link>http://ajaxian.com/archives/jquery-logging/comment-page-1#comment-257460</link>
		<dc:creator>EmEhRKay</dc:creator>
		<pubDate>Sat, 20 Oct 2007 03:48:55 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/archives/jquery-logging#comment-257460</guid>
		<description>Really, where is the footnote saying that this could be done in JavaScript, without jQuery, or any other library for that matter? 

function test(){
    console.log(&#039;---&#039;);
    return this;
}

function log(msg){
    console.log(msg);
    return this;
}

test().log(&#039;Hey, I am doing this with jQuery!&#039;).test();</description>
		<content:encoded><![CDATA[<p>Really, where is the footnote saying that this could be done in JavaScript, without jQuery, or any other library for that matter? </p>
<p>function test(){<br />
    console.log(&#8216;&#8212;&#8217;);<br />
    return this;<br />
}</p>
<p>function log(msg){<br />
    console.log(msg);<br />
    return this;<br />
}</p>
<p>test().log(&#8216;Hey, I am doing this with jQuery!&#8217;).test();</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael Geary</title>
		<link>http://ajaxian.com/archives/jquery-logging/comment-page-1#comment-257459</link>
		<dc:creator>Michael Geary</dc:creator>
		<pubDate>Sat, 20 Oct 2007 02:39:16 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/archives/jquery-logging#comment-257459</guid>
		<description>This is one of those bits of code where you smack yourself on the head and say, &quot;Why didn&#039;t I think of that?&quot;

Short, sweet, and very useful.

And dare I admit that all the time I&#039;ve been using Firebug, I didn&#039;t realize that console.log took a format string? I know, it&#039;s &lt;a href=&quot;http://www.getfirebug.com/console.html&quot; rel=&quot;nofollow&quot;&gt;right there in the docs&lt;/a&gt;, but did I ever read them? :-)</description>
		<content:encoded><![CDATA[<p>This is one of those bits of code where you smack yourself on the head and say, &#8220;Why didn&#8217;t I think of that?&#8221;</p>
<p>Short, sweet, and very useful.</p>
<p>And dare I admit that all the time I&#8217;ve been using Firebug, I didn&#8217;t realize that console.log took a format string? I know, it&#8217;s <a href="http://www.getfirebug.com/console.html" rel="nofollow">right there in the docs</a>, but did I ever read them? :-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Glen Lipka</title>
		<link>http://ajaxian.com/archives/jquery-logging/comment-page-1#comment-257444</link>
		<dc:creator>Glen Lipka</dc:creator>
		<pubDate>Fri, 19 Oct 2007 19:53:11 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/archives/jquery-logging#comment-257444</guid>
		<description>This is very clever.  I like it.</description>
		<content:encoded><![CDATA[<p>This is very clever.  I like it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dominic Mitchell</title>
		<link>http://ajaxian.com/archives/jquery-logging/comment-page-1#comment-257435</link>
		<dc:creator>Dominic Mitchell</dc:creator>
		<pubDate>Fri, 19 Oct 2007 17:45:57 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/archives/jquery-logging#comment-257435</guid>
		<description>Thanks for the link!  Really, it was more just a way of of seeing how easy it was to write a jQuery pluginâ€¦</description>
		<content:encoded><![CDATA[<p>Thanks for the link!  Really, it was more just a way of of seeing how easy it was to write a jQuery pluginâ€¦</p>
]]></content:encoded>
	</item>
</channel>
</rss>

