Tag:Nslog output in IOS

  • Timing of controlling nslog output in IOS

    Time:2021-1-9

    -(void)saveDEBUGlog{ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentDirectory = [paths objectAtIndex:0]; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@”yyyy_MM_dd_HH_mm_ss”]; NSString *currentDateStr = [dateFormatter stringFromDate:[NSDate date]]; NSString *fileName = [NSString stringWithFormat:@”testLog_%@.log”,currentDateStr]; NSString *logFilePath = [documentDirectory stringByAppendingPathComponent:fileName]; //Delete the existing file first NSFileManager *defaultManager = [NSFileManager defaultManager]; [defaultManager removeItemAtPath:logFilePath error:nil]; //Input log to file freopen([logFilePath cStringUsingEncoding:NSASCIIStringEncoding], […]