Skip to content

Instantly share code, notes, and snippets.

@NeoTeo
Created January 8, 2015 15:39
Show Gist options
  • Select an option

  • Save NeoTeo/4f25ab0ef75aba94c7aa to your computer and use it in GitHub Desktop.

Select an option

Save NeoTeo/4f25ab0ef75aba94c7aa to your computer and use it in GitHub Desktop.
Cocoa/Objective-C Macro for tagged debug logging.
// Here are the definitions of the tags used to toggle the various debug logs.
//#define TGLOG_ALL
#define TGLOG_TMP
#define TGLog(tag, msg, ...) TGLog_eval_(TGLog_do_, tag, msg, ## __VA_ARGS__)
#define TGLog_eval_(macro, ...) macro(__VA_ARGS__)
#define TGLog_do_(tag, msg, ...) \
(#tag[0] == 0 || #tag[0] == '1') ? NSLog(@"%@",[NSString stringWithFormat:msg, ## __VA_ARGS__]) : (void)0;
@NeoTeo

NeoTeo commented Jan 8, 2015

Copy link
Copy Markdown
Author

Usually included in the project's precompiled header file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment