Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Crashlytics CLS_Log vs. NSLog for production apps

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?

like image 792
Drew Avatar asked Sep 09 '13 16:09

Drew


2 Answers

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.

like image 169
iajheyst Avatar answered Nov 07 '22 10:11

iajheyst


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(...)
like image 1
Mike.R Avatar answered Nov 07 '22 10:11

Mike.R