Last active
August 29, 2015 14:05
-
-
Save nuclearghost/0cc383ce7bc1abdadf4c to your computer and use it in GitHub Desktop.
Objective C Custom Log Macros
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifdef DEBUG | |
# define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__) | |
#else | |
# define DLog(...) | |
#endif | |
// ALog always displays output regardless of the DEBUG setting | |
#define ALog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__) |
With current Xcode, you can make use of the z and t modifiers to handle NSInteger and NSUInteger without warnings, on all architectures.
You want to use %zd
for signed, %tu
for unsigned, and %tx
for hex.
From SO: http://stackoverflow.com/questions/4405006/nslog-printf-specifier-for-nsinteger
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
From Stack Overflow answer http://stackoverflow.com/questions/969130/how-to-print-out-the-method-name-and-line-number-and-conditionally-disable-nslog