Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I remove NSLogs when releasing my App

Is it advisable to do any NSLogging in a shipping app? I know that I should not in heavily used loops. Or not log too verbosely. But I am not sure if it is a good practice to do so.

Removing all the NSLogs prior to a release does not seem like a good practice too.

like image 919
Besi Avatar asked Jan 21 '12 20:01

Besi


People also ask

How do you print double values in Objective C?

We can print the double value using both %f and %lf format specifier because printf treats both float and double are same. So, we can use both %f and %lf to print a double value.


2 Answers

I think it is a good practice to not spam the user's device log.

For this, I have a macro, DebugLog, that is only active for debugging builds:

#ifdef DEBUG
#define DebugLog(fmt, ...) NSLog(fmt, __VA_ARGS__)
#else
#define DebugLog(fmt, ...)
#endif

For all log messages that are interesting to me for development, I use DebugLog. For all error messages that should be logged I use unconditional NSLog. This way the distribution builds don't clutter the user's console log. Only important messages get logged.

like image 134
DarkDust Avatar answered Sep 28 '22 23:09

DarkDust


This is one of those coding philosophy questions, but in my production apps I use asl and configure it to be off by default, but leave the option (via an entry in Info.plist) to enable various levels of logging. I tend to agree with you that too many NSLogs in a shipping app looks bad.

like image 29
sbooth Avatar answered Sep 28 '22 22:09

sbooth