I'm currently redirecting NSLog() output to a file using a call to freopen() from the App Delegate. I would like to restrict the log file size, but doing this-
unsigned long long fs = 3000;
while ([fileAttributes fileSize] < fs) {
freopen([FILEPATH cStringUsingEncoding:NSASCIIStringEncoding], "a+", stderr);
}
causes the app to be stuck with a black screen in an infinite loop. Is there any way I can set a buffer size for stderr, and then have a loop wherein I only continue to write to the file if the filesize + buffer size does not exceed the file size?