Monthly Archives: June 2013

A better NSLog!

While using objectiveC, try this macro to get detailed information with each NSLog, like line number, function name. It takes multiple arguments and can replace NSLog without a problem. Here is the macro:

//A more detailed NSLog by josellausas.com
#define NSLog(__FORMAT__, ...) NSLog((@"\n\t {LOG} %s -[Line %d]=> " __FORMAT__ "\n\n"), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)

The resulting console log will look something like this:

2013-06-18 15:12:07.062 AppName[12172:c07]

{LOG} -[ViewController viewWillAppear:] -[Line 67]=> A Log Message

 

Back to top