views:

26

answers:

1

Hi,

So the whole idea is this. I need to save those debugging console messages to some strings and then write it to the text file. I have no problem with the writing to text file part as i will be using writeData but I have problems with the first part.

in the console i see these error messages when opening corrupted image files in UIImage: : Bogus Huffman table definition or : IDAT: CRC error

How can I extract these info out from the console and copy them to a string as I need to log these information is a status file. is it possible?

I've tried doing [error localizedDescription] if it fails to open the image but the string i got is Null.

Also, I've used
freopen([logPath cStringUsingEncoding:NSASCIIStringEncoding],"a+",stderr); but the thing is it writes the data straight into a text file or log file via a file path. I am wondering if I can save it as a string so that I can customise my log file and not an identical one to the stderr.

UPDATE:

ok i have an idea, using the freopen method, can I not use "a+" to append it to the log file and use some other way to overwriting the log file repeatedly.Then I can call another function to read that file and grab the error message.

The 2nd part should be ok, but i need help for the first part. besides "a+" what else can i use? sorry i am not sure abt all these stderr stuff.

Any help will be greatly appreciated. thanks

A: 

I don't think it's possible override a file descriptor in this way. You might be able to override NSLog by defining your own, but that won't catch everything written to the file descriptor.

tc.
i see. Is there anyway I can use NSerror to log those error message out? Thanks