您的位置:首页 > 移动开发 > IOS开发

NSLog带颜色的日志输出

2015-10-10 17:12 441 查看
pragma mark - XCode Colors

define XCODE_COLORS_ESCAPE_MAC @”\033[”

define XCODE_COLORS_ESCAPE_IOS @”\xC2\xA0[“

if 0//TARGET_OS_IPHONE

define XCODE_COLORS_ESCAPE XCODE_COLORS_ESCAPE_IOS

else

define XCODE_COLORS_ESCAPE XCODE_COLORS_ESCAPE_MAC

endif

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

define LogRed(frmt, …) NSLog((XCODE_COLORS_ESCAPE @”fg249,73,72;” frmt XCODE_COLORS_RESET), ##VA_ARGS)

define LogGreen(frmt, …) NSLog((XCODE_COLORS_ESCAPE @”fg42,201,51;” frmt XCODE_COLORS_RESET), ##VA_ARGS)

define LogYellow(frmt, …) NSLog((XCODE_COLORS_ESCAPE @”fg253,177,36;” frmt XCODE_COLORS_RESET), ##VA_ARGS)

ifndef OPTIMIZE

define LogError(frmt, …) LogRed(frmt, ##VA_ARGS)

define LogWarning(frmt, …) LogYellow(frmt, ##VA_ARGS)

define LogInfo(frmt, …) LogGreen(frmt, ##VA_ARGS)

else

define LogError(frmt, …) {}

define LogWarning(frmt, …) {}

define LogInfo(frmt, …) {}

endif
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ios