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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With