Skip to content

Instantly share code, notes, and snippets.

@fra3il

fra3il/0.h Secret

Last active January 6, 2016 06:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fra3il/4957076da871ca83fe7a to your computer and use it in GitHub Desktop.
Save fra3il/4957076da871ca83fe7a to your computer and use it in GitHub Desktop.
[WP/1292] DLog + XcodeColors
// DLog
#ifdef DEBUG
#define DLog(fmt, ...) NSLog((@"%s[Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#define DLogError(fmt, ...) NSLog((XCODE_COLORS_ESCAPE @"fg231,76,60;%s[Line %d] " fmt XCODE_COLORS_RESET), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#define DLogWarn(fmt, ...) NSLog((XCODE_COLORS_ESCAPE @"fg241,196,15;%s[Line %d] " fmt XCODE_COLORS_RESET), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#define DLogInfo(fmt, ...) NSLog((XCODE_COLORS_ESCAPE @"fg26,188,156;%s[Line %d] " fmt XCODE_COLORS_RESET), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#else
#define DLog(fmt, ...)
#define DLogError(fmt, ...)
#define DLogWarn(fmt, ...)
#define DLogInfo(fmt, ...)
#endif
// XCodeColors
#define XCODE_COLORS_ESCAPE @"\033["
#define XCODE_COLORS_RESET_FG XCODE_COLORS_ESCAPE @"fg;" // Clear any foreground color
#define XCODE_COLORS_RESET_BG XCODE_COLORS_ESCAPE @"bg;" // Clear any background color
#define XCODE_COLORS_RESET XCODE_COLORS_ESCAPE @";" // Clear any foreground or background color
// DLog
#ifdef DEBUG
#define DLog(fmt, ...) CLSNSLog((@"%s[Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#define DLogError(fmt, ...) CLSNSLog((XCODE_COLORS_ESCAPE @"fg231,76,60;%s[Line %d] " fmt XCODE_COLORS_RESET), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#define DLogWarn(fmt, ...) CLSNSLog((XCODE_COLORS_ESCAPE @"fg241,196,15;%s[Line %d] " fmt XCODE_COLORS_RESET), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#define DLogInfo(fmt, ...) CLSNSLog((XCODE_COLORS_ESCAPE @"fg26,188,156;%s[Line %d] " fmt XCODE_COLORS_RESET), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#else
#define DLog(fmt, ...) CLSLog((@"%s[Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#define DLogError(fmt, ...) CLSLog((@"%s[Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#define DLogWarn(fmt, ...) CLSLog((@"%s[Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#define DLogInfo(fmt, ...) CLSLog((@"%s[Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#endif
// XCodeColors
#define XCODE_COLORS_ESCAPE @"\033["
#define XCODE_COLORS_RESET_FG XCODE_COLORS_ESCAPE @"fg;" // Clear any foreground color
#define XCODE_COLORS_RESET_BG XCODE_COLORS_ESCAPE @"bg;" // Clear any background color
#define XCODE_COLORS_RESET XCODE_COLORS_ESCAPE @";" // Clear any foreground or background color
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment