Last active
November 19, 2015 07:51
-
-
Save moliyadi/d949a705bf22e6e85c6c to your computer and use it in GitHub Desktop.
Revisions
-
moliyadi revised this gist
Nov 19, 2015 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ Just add this block of code in applicationdidFinishLaunchingWithOptionslaunchOptions method in app delegate file, and it will create a log file in app Document Directory on iphone which logs all console log events. You need to import this file from itunes to see all console events. ```Objective-C if (!isatty(STDERR_FILENO)) { //判断控制台是否已连接,http://stackoverflow.com/questions/9619708/nslog-to-both-console-and-file //将控制台内容写入文件,http://stackoverflow.com/questions/2634929/objective-c-iphone-can-we-view-console-log-on-device @@ -12,5 +12,5 @@ if (!isatty(STDERR_FILENO)) { NSString *logFilePath = [documentsDirectory stringByAppendingPathComponent:fileName]; freopen([logFilePath cStringUsingEncoding:NSASCIIStringEncoding],"a+",stderr); } ``` -
moliyadi revised this gist
Nov 19, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,4 +13,4 @@ if (!isatty(STDERR_FILENO)) { freopen([logFilePath cStringUsingEncoding:NSASCIIStringEncoding],"a+",stderr); } ``` -
moliyadi created this gist
Nov 19, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ Just add this block of code in applicationdidFinishLaunchingWithOptionslaunchOptions method in app delegate file, and it will create a log file in app Document Directory on iphone which logs all console log events. You need to import this file from itunes to see all console events. ``` if (!isatty(STDERR_FILENO)) { //判断控制台是否已连接,http://stackoverflow.com/questions/9619708/nslog-to-both-console-and-file //将控制台内容写入文件,http://stackoverflow.com/questions/2634929/objective-c-iphone-can-we-view-console-log-on-device NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *fileName =[NSString stringWithFormat:@"%@.log",[NSDate date]]; NSString *logFilePath = [documentsDirectory stringByAppendingPathComponent:fileName]; freopen([logFilePath cStringUsingEncoding:NSASCIIStringEncoding],"a+",stderr); } ```