<?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: ASL: Wrap-up</title>
	<atom:link href="http://boredzo.org/blog/archives/2008-01-28/asl-wrap-up/feed" rel="self" type="application/rss+xml" />
	<link>http://boredzo.org/blog/archives/2008-01-28/asl-wrap-up</link>
	<description>The personal weblog of Peter Hosey.</description>
	<lastBuildDate>Tue, 17 Jan 2012 18:19:08 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
	<item>
		<title>By: julian</title>
		<link>http://boredzo.org/blog/archives/2008-01-28/asl-wrap-up/comment-page-1#comment-331831</link>
		<dc:creator>julian</dc:creator>
		<pubDate>Sat, 04 Sep 2010 19:07:38 +0000</pubDate>
		<guid isPermaLink="false">http://boredzo.org/blog/archives/2008-01-28/asl-wrap-up#comment-331831</guid>
		<description>since the ASL pros seem to be here, does anyone here know how this code (1) can crash like this (2) - seems to happen on PPC with 10.5.8 only:


time_t now = time(NULL);
aslmsg query = asl_new(ASL_TYPE_QUERY);
asl_set_query(query, ASL_KEY_SENDER, &quot;kernel&quot;, ASL_QUERY_OP_EQUAL);
asl_set_query(query, ASL_KEY_MSG, &quot;I/O Error&quot;, (ASL_QUERY_OP_EQUAL &#124; ASL_QUERY_OP_SUBSTRING &#124; ASL_QUERY_OP_CASEFOLD));
asl_set_query(query, ASL_KEY_TIME, [[NSString stringWithFormat:@&quot;%lu&quot;, lastPollTime] UTF8String], ASL_QUERY_OP_GREATER_EQUAL &#124; ASL_QUERY_OP_NUMERIC);
asl_set_query(query, ASL_KEY_TIME, [[NSString stringWithFormat:@&quot;%lu&quot;, now] UTF8String], ASL_QUERY_OP_LESS &#124; ASL_QUERY_OP_NUMERIC);
aslresponse response = asl_search(NULL, query);




Thread 0 Crashed:
0   libSystem.B.dylib             	0x94f45a60 strcmp + 192
1   libSystem.B.dylib             	0x9505b3e0 asl_file_fetch_object + 172
2   libSystem.B.dylib             	0x9505bad4 asl_file_fetch_pos + 968
3   libSystem.B.dylib             	0x9505c264 asl_file_match_next + 168
4   libSystem.B.dylib             	0x9505d9e8 asl_file_list_match_timeout + 348
5   libSystem.B.dylib             	0x9505a694 asl_store_match_timeout + 276
6   libSystem.B.dylib             	0x9505a6d0 asl_store_match + 20
7   libSystem.B.dylib             	0x95060c10 asl_search + 136</description>
		<content:encoded><![CDATA[<p>since the ASL pros seem to be here, does anyone here know how this code (1) can crash like this (2) &#8211; seems to happen on PPC with 10.5.8 only:</p>
<p>time_t now = time(NULL);<br />
aslmsg query = asl_new(ASL_TYPE_QUERY);<br />
asl_set_query(query, ASL_KEY_SENDER, &#8220;kernel&#8221;, ASL_QUERY_OP_EQUAL);<br />
asl_set_query(query, ASL_KEY_MSG, &#8220;I/O Error&#8221;, (ASL_QUERY_OP_EQUAL | ASL_QUERY_OP_SUBSTRING | ASL_QUERY_OP_CASEFOLD));<br />
asl_set_query(query, ASL_KEY_TIME, [[NSString stringWithFormat:@"%lu", lastPollTime] UTF8String], ASL_QUERY_OP_GREATER_EQUAL | ASL_QUERY_OP_NUMERIC);<br />
asl_set_query(query, ASL_KEY_TIME, [[NSString stringWithFormat:@"%lu", now] UTF8String], ASL_QUERY_OP_LESS | ASL_QUERY_OP_NUMERIC);<br />
aslresponse response = asl_search(NULL, query);</p>
<p>Thread 0 Crashed:<br />
0   libSystem.B.dylib             	0x94f45a60 strcmp + 192<br />
1   libSystem.B.dylib             	0x9505b3e0 asl_file_fetch_object + 172<br />
2   libSystem.B.dylib             	0x9505bad4 asl_file_fetch_pos + 968<br />
3   libSystem.B.dylib             	0x9505c264 asl_file_match_next + 168<br />
4   libSystem.B.dylib             	0x9505d9e8 asl_file_list_match_timeout + 348<br />
5   libSystem.B.dylib             	0x9505a694 asl_store_match_timeout + 276<br />
6   libSystem.B.dylib             	0x9505a6d0 asl_store_match + 20<br />
7   libSystem.B.dylib             	0x95060c10 asl_search + 136</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Hosey</title>
		<link>http://boredzo.org/blog/archives/2008-01-28/asl-wrap-up/comment-page-1#comment-206931</link>
		<dc:creator>Peter Hosey</dc:creator>
		<pubDate>Sun, 29 Jun 2008 11:11:24 +0000</pubDate>
		<guid isPermaLink="false">http://boredzo.org/blog/archives/2008-01-28/asl-wrap-up#comment-206931</guid>
		<description>Mattias: Console&#039;s use of a table view suggests that it&#039;s probably working with aslmsg objects, not any of the external representations. Remember, those are database queries, not plain-text log files.</description>
		<content:encoded><![CDATA[<p>Mattias: Console&#8217;s use of a table view suggests that it&#8217;s probably working with aslmsg objects, not any of the external representations. Remember, those are database queries, not plain-text log files.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mattias</title>
		<link>http://boredzo.org/blog/archives/2008-01-28/asl-wrap-up/comment-page-1#comment-206926</link>
		<dc:creator>Mattias</dc:creator>
		<pubDate>Sun, 29 Jun 2008 10:45:27 +0000</pubDate>
		<guid isPermaLink="false">http://boredzo.org/blog/archives/2008-01-28/asl-wrap-up#comment-206926</guid>
		<description>Excellent series of posts, congratulations on helping the world becoming a better place for us programmers.

Now, I&#039;ve noticed that if I set the ASL_OPT_STDERR flag, I really cannot seem to get my printouts to have proper linebreaks in my shell (nor in Xcode&#039;s terminal). I recognize that this is the same problem as you reported in rdar://problem/5695926. Take this as an example: &quot;This is\n a linebreak \n and here comes one more\n&quot;. That string will be printed exactly as is, that is \n isn&#039;t treated like a line break. However, Console.app seems to be displaying the string just as I intended it to be seen, with \n converted to a newline.

Again; thanks for some really good posts.</description>
		<content:encoded><![CDATA[<p>Excellent series of posts, congratulations on helping the world becoming a better place for us programmers.</p>
<p>Now, I&#8217;ve noticed that if I set the ASL_OPT_STDERR flag, I really cannot seem to get my printouts to have proper linebreaks in my shell (nor in Xcode&#8217;s terminal). I recognize that this is the same problem as you reported in rdar://problem/5695926. Take this as an example: &#8220;This is\n a linebreak \n and here comes one more\n&#8221;. That string will be printed exactly as is, that is \n isn&#8217;t treated like a line break. However, Console.app seems to be displaying the string just as I intended it to be seen, with \n converted to a newline.</p>
<p>Again; thanks for some really good posts.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Hosey</title>
		<link>http://boredzo.org/blog/archives/2008-01-28/asl-wrap-up/comment-page-1#comment-169607</link>
		<dc:creator>Peter Hosey</dc:creator>
		<pubDate>Wed, 27 Feb 2008 04:47:27 +0000</pubDate>
		<guid isPermaLink="false">http://boredzo.org/blog/archives/2008-01-28/asl-wrap-up#comment-169607</guid>
		<description>Brian K.: You&#039;re absolutely right. Fixed.</description>
		<content:encoded><![CDATA[<p>Brian K.: You&#8217;re absolutely right. Fixed.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian K.</title>
		<link>http://boredzo.org/blog/archives/2008-01-28/asl-wrap-up/comment-page-1#comment-169599</link>
		<dc:creator>Brian K.</dc:creator>
		<pubDate>Wed, 27 Feb 2008 03:42:21 +0000</pubDate>
		<guid isPermaLink="false">http://boredzo.org/blog/archives/2008-01-28/asl-wrap-up#comment-169599</guid>
		<description>&lt;p&gt;As pointed out by others, excellent, well detailed series.&lt;/p&gt;

&lt;p&gt;I think in your summary, the asl_log call is missing a parameter for level:&lt;/p&gt;

&lt;pre&gt;asl_log(client, /*msg*/ NULL, &quot;printf-style format; interpolates values, such as %i&quot;, 42);&lt;/pre&gt;

&lt;p&gt;should be (?):&lt;/p&gt;

&lt;pre&gt;asl_log(client, /*msg*/ NULL, ASL_LEVEL_XXX, &quot;printf-style format; interpolates values, such as %i&quot;, 42);&lt;/pre&gt;

</description>
		<content:encoded><![CDATA[<p>As pointed out by others, excellent, well detailed series.</p>
<p>I think in your summary, the asl_log call is missing a parameter for level:</p>
<pre>asl_log(client, /*msg*/ NULL, "printf-style format; interpolates values, such as %i", 42);</pre>
<p>should be (?):</p>
<pre>asl_log(client, /*msg*/ NULL, ASL_LEVEL_XXX, "printf-style format; interpolates values, such as %i", 42);</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Hosey</title>
		<link>http://boredzo.org/blog/archives/2008-01-28/asl-wrap-up/comment-page-1#comment-163406</link>
		<dc:creator>Peter Hosey</dc:creator>
		<pubDate>Sun, 10 Feb 2008 18:05:25 +0000</pubDate>
		<guid isPermaLink="false">http://boredzo.org/blog/archives/2008-01-28/asl-wrap-up#comment-163406</guid>
		<description>Ken T.: Very good suggestion. Thanks.</description>
		<content:encoded><![CDATA[<p>Ken T.: Very good suggestion. Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ken T.</title>
		<link>http://boredzo.org/blog/archives/2008-01-28/asl-wrap-up/comment-page-1#comment-163338</link>
		<dc:creator>Ken T.</dc:creator>
		<pubDate>Sun, 10 Feb 2008 14:58:02 +0000</pubDate>
		<guid isPermaLink="false">http://boredzo.org/blog/archives/2008-01-28/asl-wrap-up#comment-163338</guid>
		<description>I would recommend using the pthread per-thread data routines:

Early in your application startup, create a key for the per-thread ASL connection using pthread_key_create().  Pass in a destructor routine that closes the connection.  That way, each thread&#039;s connection will be automatically closed when that thread exits.  Store the key in a global variable.

When you need to log, call pthread_getspecific() to obtain the thread&#039;s ASL connection.  If it comes back NULL, then this is the first time you&#039;re logging for that particular thread.  In that case, create the connection for the thread and store it using pthread_setspecific().  The business of getting the connection and creating it if necessary should be hidden within a function, naturally.

If you prefer, in Cocoa you can use -[NSThread threadDictionary] to store the connection.  In that case, you&#039;d define your own class for holding an ASL connection, whose dealloc would close the connection.  This seems to add complexity for no apparent benefit, though.</description>
		<content:encoded><![CDATA[<p>I would recommend using the pthread per-thread data routines:</p>
<p>Early in your application startup, create a key for the per-thread ASL connection using pthread_key_create().  Pass in a destructor routine that closes the connection.  That way, each thread&#8217;s connection will be automatically closed when that thread exits.  Store the key in a global variable.</p>
<p>When you need to log, call pthread_getspecific() to obtain the thread&#8217;s ASL connection.  If it comes back NULL, then this is the first time you&#8217;re logging for that particular thread.  In that case, create the connection for the thread and store it using pthread_setspecific().  The business of getting the connection and creating it if necessary should be hidden within a function, naturally.</p>
<p>If you prefer, in Cocoa you can use -[NSThread threadDictionary] to store the connection.  In that case, you&#8217;d define your own class for holding an ASL connection, whose dealloc would close the connection.  This seems to add complexity for no apparent benefit, though.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Hosey</title>
		<link>http://boredzo.org/blog/archives/2008-01-28/asl-wrap-up/comment-page-1#comment-159078</link>
		<dc:creator>Peter Hosey</dc:creator>
		<pubDate>Tue, 29 Jan 2008 21:23:23 +0000</pubDate>
		<guid isPermaLink="false">http://boredzo.org/blog/archives/2008-01-28/asl-wrap-up#comment-159078</guid>
		<description>Jeff: I got a similar question by email.

If you have multiple objects that each use one (&lt;em&gt;and only one&lt;/em&gt;) thread, you can just put the connection in their class as an ivar.

If you have one object which messages from multiple sources pass through, I would suggest using &lt;code&gt;performSelectorOnMainThread:&lt;/code&gt; to fob all the logging off on the main thread. This is a bottleneck, but you&#039;d need &lt;em&gt;a lot&lt;/em&gt; of messages to come in at the same time to cause a performance problem.

I should probably add this to the client connections post.</description>
		<content:encoded><![CDATA[<p>Jeff: I got a similar question by email.</p>
<p>If you have multiple objects that each use one (<em>and only one</em>) thread, you can just put the connection in their class as an ivar.</p>
<p>If you have one object which messages from multiple sources pass through, I would suggest using <code>performSelectorOnMainThread:</code> to fob all the logging off on the main thread. This is a bottleneck, but you&#8217;d need <em>a lot</em> of messages to come in at the same time to cause a performance problem.</p>
<p>I should probably add this to the client connections post.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff Johnson</title>
		<link>http://boredzo.org/blog/archives/2008-01-28/asl-wrap-up/comment-page-1#comment-159004</link>
		<dc:creator>Jeff Johnson</dc:creator>
		<pubDate>Tue, 29 Jan 2008 15:26:51 +0000</pubDate>
		<guid isPermaLink="false">http://boredzo.org/blog/archives/2008-01-28/asl-wrap-up#comment-159004</guid>
		<description>Thanks, Peter!  Great work.  Maybe the ADC docs should just point here. ;)

Question: what&#039;s your view on how to deal most effectively with logging from multiple threads in an app?</description>
		<content:encoded><![CDATA[<p>Thanks, Peter!  Great work.  Maybe the ADC docs should just point here. ;)</p>
<p>Question: what&#8217;s your view on how to deal most effectively with logging from multiple threads in an app?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Blake C.</title>
		<link>http://boredzo.org/blog/archives/2008-01-28/asl-wrap-up/comment-page-1#comment-158901</link>
		<dc:creator>Blake C.</dc:creator>
		<pubDate>Tue, 29 Jan 2008 07:23:46 +0000</pubDate>
		<guid isPermaLink="false">http://boredzo.org/blog/archives/2008-01-28/asl-wrap-up#comment-158901</guid>
		<description>A most excellent series of posts, sir! I&#039;ve learned quite a bit from your research, and I look forward to more of the same. Thanx much for taking the time to share this with us all :)</description>
		<content:encoded><![CDATA[<p>A most excellent series of posts, sir! I&#8217;ve learned quite a bit from your research, and I look forward to more of the same. Thanx much for taking the time to share this with us all :)</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.160 seconds -->

