开发者

iPhone: Help. Extracting stderr/messages from GDB and copy to string

开发者 https://www.devze.com 2023-01-05 09:24 出处:网络
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 w

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 possibl开发者_运维问答e?

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消