Posted By

zingo on 10/20/09


Tagged

objc macro gcc NSLog


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

davidsi
Tintenklecks
cnathan


Detailed NSLog() via a Preprocessor Macro


 / Published in: Objective C
 

URL: http://www.degutis.org/dev/2009/04/14/detailedlog/

Ever needed to see more context surrounding your NSLog statement to help you debug in the console?

  1. #define DetailedLog(str, args...) NSLog\
  2. (@"\n-------------\nBetter Log\n%s:%d\n%@\n[%s]\n\n[%@]\n-------------\n",\
  3. strrchr(__FILE__, '/'), __LINE__, self, sel_getName(_cmd),\
  4. [NSString stringWithFormat:str , ## args ] )
  5.  
  6. // this function was improved to work in functions as well as methods:
  7. #define DetailedLog(str, args...)\
  8. NSLog(@"\n-------------\nBetter Log\n%s:%d\n%s\n\n[%@]\n-------------\n",\
  9. strrchr(__FILE__, '/'), __LINE__, __PRETTY_FUNCTION__,\
  10. [NSString stringWithFormat:str , ## args ] )

Report this snippet  

You need to login to post a comment.