开发者

Can I leave logging in Release builds?

开发者 https://www.devze.com 2023-01-13 17:38 出处:网络
I\'ve read this question which advocates taking NSLog statements out of Release builds. Is it acceptable to, instead of cluttering the main log up with junk, write it to Apple System Log instead, the

I've read this question which advocates taking NSLog statements out of Release builds.

Is it acceptable to, instead of cluttering the main log up with junk, write it to Apple System Log instead, then it'd be hidden from the main log开发者_JS百科?

Or am I just overcomplicating things? Are there any instances where logging has been useful to you in pinpointing a bug in an app after release?


I find that log messages I add during development generally do one of three things:

  1. Aid in debugging and testing new, unfinished features and code paths
  2. Provide information about the normal operation of the program such as task completion and common error conditions (e.g. no internet connection).
  3. Provide detailed information about unusual or unexpected events, including error conditions that are dangerous or not specifically handled, software updates, and malformed data coming from a server connection or file

Messages in category one I usually remove when the feature is complete, messages in category two I filter out with a macro like the one in the linked question, and messages in category three I leave in the release.

Obviously the lines are blurry, but I think it comes down to respecting the log. If your application floods it with information that isn't useful, it could make it difficult to notice errors from other applications, and will be a (small) resource drain.

Using ASL functions to log messages with lower priorities like debug and info that won't be visible to most users is a great idea for messages that fall in a grey area.


There is also this question that asks about any performance advantage by taking the statements out. The jury looks to still be out on any hard numbers, but conventional wisdom says to remove them by making their inclusion conditional with a macro. You still get your debugging info, and the user gets an app free of clutter.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号