Skip to content

Instantly share code, notes, and snippets.

@fpillet
Created December 2, 2010 16:50
Show Gist options
  • Save fpillet/725650 to your computer and use it in GitHub Desktop.
Save fpillet/725650 to your computer and use it in GitHub Desktop.
NSLogger example macros
// Example macros that you can leave in production code, and turn on a flag to activate logging
#import "LoggerClient.h"
extern BOOL gLoggingEnabled;
#define LOG_APP(...) if (gLoggingEnabled) LogMessageF(__FILE__,__LINE__,__FUNCTION__,@"app", ##__VA_ARGS__); else do {} while(0)
#define LOG_CACHE(...) if (gLoggingEnabled) LogMessageF(__FILE__,__LINE__,__FUNCTION__,@"cache", ##__VA_ARGS__); else do {} while(0)
#define LOG_XML_PARSING(...) if (gLoggingEnabled) LogMessageF(__FILE__,__LINE__,__FUNCTION__,@"xml", ##__VA_ARGS__); else do {} while(0)
#define LOG_SOUNDS(...) if (gLoggingEnabled) LogMessageF(__FILE__,__LINE__,__FUNCTION__,@"sounds", ##__VA_ARGS__); else do {} while(0)
#define LOG_TIMERS(...) if (gLoggingEnabled) LogMessageF(__FILE__,__LINE__,__FUNCTION__,@"timers", ##__VA_ARGS__); else do {} while(0)
#define LOG_MATH_EXPRESSIONS(...) if (gLoggingEnabled) LogMessageF(__FILE__,__LINE__,__FUNCTION__,@"math", ##__VA_ARGS__); else do {} while(0)
#define LOG_ANIMATIONS(...) if (gLoggingEnabled) LogMessageF(__FILE__,__LINE__,__FUNCTION__,@"animations", ##__VA_ARGS__); else do {} while(0)
#define LOG_WEBVIEW(...) if (gLoggingEnabled) LogMessageF(__FILE__,__LINE__,__FUNCTION__,@"web", ##__VA_ARGS__); else do {} while(0)
#define LOG_EXCEPTIONS(...) if (gLoggingEnabled) LogMessageF(__FILE__,__LINE__,__FUNCTION__,nil, 0, ##__VA_ARGS__); else do {} while(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment