<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet title="XSL formatting" type="text/xsl" href="http://blog.visuaweb.com/index.php/feed/rss2/xslt" ?><rss version="2.0"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:wfw="http://wellformedweb.org/CommentAPI/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
  <title>VisuaBlog - Debug</title>
  <link>http://blog.visuaweb.com/index.php/</link>
  <description></description>
  <language>fr</language>
  <pubDate>Mon, 15 Dec 2008 20:24:26 +0100</pubDate>
  <copyright></copyright>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Dotclear</generator>
  
    
  <item>
    <title>Débuggage Iphone : pas facile ! Une solution autour de NSLog.</title>
    <link>http://blog.visuaweb.com/index.php/post/2007/12/12/Debuggage-Iphone-%3A-pas-facile-Reorienter-NSLog-vers-un-fichier</link>
    <guid isPermaLink="false">urn:md5:2acc1c5af53db5a78f0390e1cf54d853</guid>
    <pubDate>Wed, 12 Dec 2007 18:48:00 +0100</pubDate>
    <dc:creator>Jeremie Engel</dc:creator>
        <category>IPhone</category>
        <category>Debug</category><category>Iphone Source</category><category>NSLog</category>    
    <description>    &lt;div&gt;En attendant des solution pour tracer et debugger correctement une appli Iphone, voici un moyen simple qui permet de récupérer les résultats des NSLog dans une application lancée par le Springboard : réorienter les NSLog vers un fichier.&lt;br /&gt;&lt;br /&gt;
Une macro remplace le NSLog.&lt;/div&gt;
&lt;div&gt;Les données sont écrites dans /var/root/VSLog.txt&lt;/div&gt;
&lt;div&gt;&lt;a href=&quot;http://blog.visuaweb.com/public/VSLog.zip&quot;&gt;Les sources sont téléchargeables ici&lt;/a&gt;.&lt;/div&gt;
&lt;div&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #007400&quot;&gt;/*&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #007400&quot;&gt; *  VSLog.h&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #007400&quot;&gt; *  Created by Jérémie Engel 12/12/2007.&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #007400&quot;&gt; *  Copyright 2007 VisuaWeb. All rights reserved.&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #007400&quot;&gt; *&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #007400&quot;&gt; */&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #c41a16&quot;&gt;&lt;span style=&quot;color: #643820&quot;&gt;#include &lt;/span&gt;&amp;lt;Foundation/Foundation.h&amp;gt;&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #c41a16&quot;&gt;&lt;span style=&quot;color: #643820&quot;&gt;#include &lt;/span&gt;&amp;lt;CoreFoundation/CoreFoundation.h&amp;gt;&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #643820&quot;&gt;#define VSLog(s,...) [VSLog LogToDefaultFile:(s),##__VA_ARGS__]&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #643820&quot;&gt;#define NSLog(s,...) [VSLog LogToDefaultFile:(s),##__VA_ARGS__]&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco&quot;&gt;&lt;span style=&quot;color: #aa0d91&quot;&gt;@interface&lt;/span&gt; VSLog : &lt;span style=&quot;color: #5c2699&quot;&gt;NSObject&lt;/span&gt; {&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #5c2699&quot;&gt;va_list&lt;span style=&quot;color: #000000&quot;&gt; ap;&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco&quot;&gt;&lt;span style=&quot;color: #5c2699&quot;&gt;NSFileHandle&lt;/span&gt; *fileOutHandle;&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco&quot;&gt;&lt;span style=&quot;color: #5c2699&quot;&gt;NSString&lt;/span&gt; *strToWrite, *fileOut;&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco&quot;&gt;}&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco&quot;&gt;+ (&lt;span style=&quot;color: #aa0d91&quot;&gt;void&lt;/span&gt;)LogToDefaultFile: (&lt;span style=&quot;color: #5c2699&quot;&gt;NSString&lt;/span&gt;*)format, ...;&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #aa0d91&quot;&gt;@end&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #007400&quot;&gt;/*&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #007400&quot;&gt; *  VSLog.m&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #007400&quot;&gt; *  Created by Jérémie Engel 12/12/2007.&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #007400&quot;&gt; *  Copyright 2007 VisuaWeb. All rights reserved.&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #007400&quot;&gt; *&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #007400&quot;&gt; */&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #643820&quot;&gt;#include &lt;span style=&quot;color: #c41a16&quot;&gt;&quot;VSLog.h&quot;&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #aa0d91&quot;&gt;@implementation&lt;span style=&quot;color: #000000&quot;&gt; VSLog&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco&quot;&gt;+ (&lt;span style=&quot;color: #aa0d91&quot;&gt;void&lt;/span&gt;)LogToDefaultFile:(&lt;span style=&quot;color: #5c2699&quot;&gt;NSString&lt;/span&gt;*)format, ...; {&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #5c2699&quot;&gt;va_list&lt;span style=&quot;color: #3f6e74&quot;&gt;ap&lt;/span&gt;&lt;span style=&quot;color: #000000&quot;&gt;;&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #3f6e74&quot;&gt;&lt;span style=&quot;color: #5c2699&quot;&gt;NSFileHandle&lt;/span&gt;&lt;span style=&quot;color: #000000&quot;&gt; *&lt;/span&gt;fileOutHandle&lt;span style=&quot;color: #000000&quot;&gt;;&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #3f6e74&quot;&gt;&lt;span style=&quot;color: #5c2699&quot;&gt;NSString&lt;/span&gt;&lt;span style=&quot;color: #000000&quot;&gt; *&lt;/span&gt;strToWrite&lt;span style=&quot;color: #000000&quot;&gt;, *&lt;/span&gt;fileOut&lt;span style=&quot;color: #000000&quot;&gt;;&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco&quot;&gt;va_start(&lt;span style=&quot;color: #3f6e74&quot;&gt;ap&lt;/span&gt;,format);&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #2e0d6e&quot;&gt;&lt;span style=&quot;color: #3f6e74&quot;&gt;strToWrite&lt;/span&gt;&lt;span style=&quot;color: #000000&quot;&gt;=[[[&lt;/span&gt;&lt;span style=&quot;color: #5c2699&quot;&gt;NSString&lt;/span&gt;alloc&lt;span style=&quot;color: #000000&quot;&gt;] &lt;/span&gt;initWithFormat&lt;span style=&quot;color: #000000&quot;&gt;:format &lt;/span&gt;arguments&lt;span style=&quot;color: #000000&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #3f6e74&quot;&gt;ap&lt;/span&gt;&lt;span style=&quot;color: #000000&quot;&gt;] &lt;/span&gt;stringByAppendingString&lt;span style=&quot;color: #000000&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #c41a16&quot;&gt;@&quot;\n&quot;&lt;/span&gt;&lt;span style=&quot;color: #000000&quot;&gt;];&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco&quot;&gt;va_end(&lt;span style=&quot;color: #3f6e74&quot;&gt;ap&lt;/span&gt;);&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #2e0d6e&quot;&gt;&lt;span style=&quot;color: #aa0d91&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #000000&quot;&gt; (![[&lt;/span&gt;&lt;span style=&quot;color: #5c2699&quot;&gt;NSFileManager&lt;/span&gt;defaultManager&lt;span style=&quot;color: #000000&quot;&gt;] &lt;/span&gt;fileExistsAtPath&lt;span style=&quot;color: #000000&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #c41a16&quot;&gt;@&quot;/var/root/VSLog.txt&quot;&lt;/span&gt;&lt;span style=&quot;color: #000000&quot;&gt;]) [[&lt;/span&gt;&lt;span style=&quot;color: #5c2699&quot;&gt;NSFileManager&lt;/span&gt;defaultManager&lt;span style=&quot;color: #000000&quot;&gt;] &lt;/span&gt;createFileAtPath&lt;span style=&quot;color: #000000&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #c41a16&quot;&gt;@&quot;/var/root/VSLog.txt&quot;&lt;/span&gt;contents&lt;span style=&quot;color: #000000&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #aa0d91&quot;&gt;nil&lt;/span&gt;attributes&lt;span style=&quot;color: #000000&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #aa0d91&quot;&gt;nil&lt;/span&gt;&lt;span style=&quot;color: #000000&quot;&gt;];&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #2e0d6e&quot;&gt;&lt;span style=&quot;color: #3f6e74&quot;&gt;fileOut&lt;/span&gt;&lt;span style=&quot;color: #000000&quot;&gt; = [[&lt;/span&gt;&lt;span style=&quot;color: #5c2699&quot;&gt;NSString&lt;/span&gt;stringWithString&lt;span style=&quot;color: #000000&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #c41a16&quot;&gt;@&quot;/var/root/VSLog.txt&quot;&lt;/span&gt;&lt;span style=&quot;color: #000000&quot;&gt;] &lt;/span&gt;stringByExpandingTildeInPath&lt;span style=&quot;color: #000000&quot;&gt;];&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #2e0d6e&quot;&gt;&lt;span style=&quot;color: #3f6e74&quot;&gt;fileOutHandle&lt;/span&gt;&lt;span style=&quot;color: #000000&quot;&gt; = [&lt;/span&gt;&lt;span style=&quot;color: #5c2699&quot;&gt;NSFileHandle&lt;/span&gt;fileHandleForWritingAtPath&lt;span style=&quot;color: #000000&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: #3f6e74&quot;&gt;fileOut&lt;/span&gt;&lt;span style=&quot;color: #000000&quot;&gt;];&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #2e0d6e&quot;&gt;&lt;span style=&quot;color: #000000&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #3f6e74&quot;&gt;fileOutHandle&lt;/span&gt;truncateFileAtOffset&lt;span style=&quot;color: #000000&quot;&gt;:[&lt;/span&gt;&lt;span style=&quot;color: #3f6e74&quot;&gt;fileOutHandle&lt;/span&gt;seekToEndOfFile&lt;span style=&quot;color: #000000&quot;&gt;]];&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #2e0d6e&quot;&gt;&lt;span style=&quot;color: #000000&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #3f6e74&quot;&gt;fileOutHandle&lt;/span&gt;writeData&lt;span style=&quot;color: #000000&quot;&gt;:[&lt;/span&gt;&lt;span style=&quot;color: #3f6e74&quot;&gt;strToWrite&lt;/span&gt;dataUsingEncoding&lt;span style=&quot;color: #000000&quot;&gt;:&lt;/span&gt;NSUTF8StringEncoding&lt;span style=&quot;color: #000000&quot;&gt;]];&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #3f6e74&quot;&gt;&lt;span style=&quot;color: #000000&quot;&gt;[&lt;/span&gt;fileOutHandle&lt;span style=&quot;color: #2e0d6e&quot;&gt;closeFile&lt;/span&gt;&lt;span style=&quot;color: #000000&quot;&gt;];&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #3f6e74&quot;&gt;&lt;span style=&quot;color: #000000&quot;&gt;[&lt;/span&gt;fileOutHandle&lt;span style=&quot;color: #2e0d6e&quot;&gt;release&lt;/span&gt;&lt;span style=&quot;color: #000000&quot;&gt;];&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #3f6e74&quot;&gt;&lt;span style=&quot;color: #000000&quot;&gt;[&lt;/span&gt;fileOut&lt;span style=&quot;color: #2e0d6e&quot;&gt;release&lt;/span&gt;&lt;span style=&quot;color: #000000&quot;&gt;];&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #3f6e74&quot;&gt;&lt;span style=&quot;color: #000000&quot;&gt;[&lt;/span&gt;strToWrite&lt;span style=&quot;color: #2e0d6e&quot;&gt;release&lt;/span&gt;&lt;span style=&quot;color: #000000&quot;&gt;];&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #aa0d91&quot;&gt;return&lt;span style=&quot;color: #000000&quot;&gt;;&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco&quot;&gt;}&lt;/p&gt;
&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #aa0d91&quot;&gt;@end&lt;/p&gt;
&lt;/div&gt;</description>
    
    
    
          <comments>http://blog.visuaweb.com/index.php/post/2007/12/12/Debuggage-Iphone-%3A-pas-facile-Reorienter-NSLog-vers-un-fichier#comment-form</comments>
      <wfw:comment>http://blog.visuaweb.com/index.php/post/2007/12/12/Debuggage-Iphone-%3A-pas-facile-Reorienter-NSLog-vers-un-fichier#comment-form</wfw:comment>
      <wfw:commentRss>http://blog.visuaweb.com/index.php/feed/rss2/comments/9</wfw:commentRss>
      </item>
    
</channel>
</rss>