NSLog带颜色的日志输出
2015-10-10 17:12
489 查看
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
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
相关文章推荐
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 不可修补的 iOS 漏洞可能导致 iPhone 4s 到 iPhone X 永久越狱
- iOS 12.4 系统遭黑客破解,漏洞危及数百万用户
- 每日安全资讯:NSO,一家专业入侵 iPhone 的神秘公司
- [转][源代码]Comex公布JailbreakMe 3.0源代码
- js判断客户端是iOS还是Android等移动终端的方法
- IOS开发环境windows化攻略
- .net平台推送ios消息的实现方法
- 探讨Android与iOS,我们将何去何从?
- Android、iOS和Windows Phone中的推送技术详解
- IOS 改变键盘颜色代码
- 举例详解iOS开发过程中的沙盒机制与文件
- Android和IOS的浏览器中检测是否安装某个客户端的方法
- javascript实现阻止iOS APP中的链接打开Safari浏览器
- IOS开发第三方语音-微信语音
- iOS开发之路--微博OAuth授权_取得用户授权的accessToken
- 基于UIControl控件实现ios点赞功能
- iOS开发中实现邮件和短信发送的简单示例