Skip to content

Instantly share code, notes, and snippets.

@theand
Last active October 12, 2015 01:28
Show Gist options
  • Save theand/3950325 to your computer and use it in GitHub Desktop.
Save theand/3950325 to your computer and use it in GitHub Desktop.
#ObjectiveC DebugLog macro
/*
DebugLog for Objective-C
from http://stackoverflow.com/questions/300673/is-it-true-that-one-should-not-use-nslog-on-production-code/302246#302246
paste in .pch
*/
#define DEBUG_MODE
#ifdef DEBUG_MODE
#define DebugLog( s, ... ) NSLog( @"<%p %@:(%d)> %@", self, [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__] )
#else
#define DebugLog( s, ... )
#endif
/* modified macro */
#define DEBUG_MODE
#ifdef DEBUG_MODE
#define DebugLog( s, ... ) NSLog( @"<%@:%s(%d) >\n\t%@", [[NSString stringWithUTF8String:__FILE__] lastPathComponent], sel_getName(_cmd), __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__] )
#else
#define DebugLog( s, ... )
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment