Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSLog style debug messages from C code

I have some C code in a static library that I'm compiling into an iPhone app. I'd like to print some debug messages to the console; is there something like NSLog I should use? I'm guessing NSLog only works for the Objective-C parts of the program.

EDIT: fprintf(stdout, fmt...) and fprintf(stderr, fmt...) don't work either.. any idea why they don't? Should they work?

like image 659
Anthony Blake Avatar asked Dec 04 '11 01:12

Anthony Blake


People also ask

Where does NSLog write to?

NSLog outputs messages to the Apple System Log facility or to the Console app (usually prefixed with the time and the process id). Many of the system frameworks use NSLog for logging exceptions and errors, but there is no requirement to restrict its usage to those purposes.

How do I print from Xcode?

How to print () to Xcode console in SwiftUI ?, Try right-clicking on the live preview play button and selecting 'Debug Preview from the popup. The print function prints messages in the Xcode console when debugging apps.


1 Answers

you can always do the classic:

fprintf(stderr, "hi, this is a log line: %s", aStringVariable);
like image 163
Michael Dautermann Avatar answered Sep 28 '22 01:09

Michael Dautermann