Created
June 10, 2013 10:26
-
-
Save agiletalk/5747782 to your computer and use it in GitHub Desktop.
NSLog To File
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 characters
@implementation UIApplication (Logging) | |
+ (void)redirectConsoleLogToDocumentFolder:(NSString *)filename | |
{ | |
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); | |
NSString *documentsDirectory = [paths objectAtIndex:0]; | |
NSString *logPath = [documentsDirectory stringByAppendingPathComponent:filename]; | |
freopen([logPath cStringUsingEncoding:NSASCIIStringEncoding], "a+", stderr); | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment