Question

No really a specific question, but I was curious if anyone has ever used CLSLog() or CLSNSLog() provided by the Crashlytics SDK?

Up until now, my apps have been fairly small and I've just been leaving the NSLog's on all the time and even submitting the final app with them still in-tact. In hindsight, I probably should turn these off, use some other logging system, or #define a DEBUG var that will disable them upon release as I've seen people discuss in other posts.

At any rate, just curious if anyone's used it before?

Was it helpful?

Solution

The best approach to this would be to declare a preprocessor variable called DEBUG

in the header, include:

#define DEBUG 1

After that, for debug purposes, set DEBUG to 1, and NSLog everything.

#if DEBUG==1
   NSLog(@"debug mode activated, value for certain variables is: %d", i);
#endif

Before you ship the product, just change

#define DEBUG 0

That way, you can just leave the entire code for debugging in the app, and keep it for further development

CLS_LOG from Crashlytics gives you access to the Log of the app from the Crashlytics website. It also gathers information about the crash, memory warnings, how many users crashed at a certain point, etc.

Happy coding!

edit:

I forgot to add one thing: for the application I'm working on right now, in the prefix, we defined:

#define NSLog(...) CLS_LOG(__VA_ARGS__)

So, we don't ever use CLS_LOG explicitly. We only use NSLog, but all the NSLogs make it to the Crashlytics dashboard.

OTHER TIPS

I created some .h file with all the common constants that I need to use and added it .pch file (in order not to make mess in it).I also imported CrashLytics via pods (some why .pch didn't recognised it if I included in project the usual way)

#ifdef DEBUG
#define NSLog(...) CLS_LOG(__VA_ARGS__)
#define ServerURL    @"http://TestServer"
#else
#define ServerURL    @"http://RealServer" 
#define NSLog(...)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top