dNSLog – simple debug only NSLog

Recently read a blog post by Carbon 5 on using Xcode 4 logging breakpoints to do logging. Thought I’d post what I’ve used for over a decade. It’s dead simple; no logging levels, no extra output on each log statement (makes log lines too long in my experience and adds noise). Anyway, I have fancier versions for more control/configurability, but this is the bare-bones simplest version for quick prototyping. I use it for iOS and Mac OS X.

I define DEBUG=1 in my project preprocessor macros, only for the Debug configuration.

Then use dNSLog(@"foo is: %@", foo); for any non-release log statement. The dElseNSLogversion is useful for when you only want an else clause and log statement in debug builds. It allows you to do things like: