安装XcodeColors插件 下载地址:https://github.com/robbiehanson/XcodeColors 安装方法: 下载并解压缩XcodeColors-master.zip 打开XcodeColors项目,编译项目能够自动将插件安装至~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/XcodeColors.xcplugin 从新启动Xcode 再次打开XcodeColors项目 运行TestXcodeColors测试插件是否安装成功git
下载CocoaLumberjack开源框架 下载地址:https://github.com/CocoaLumberjack/CocoaLumberjackgithub
新建项目,将CocoaLumberjack拖入项目中app
建立Common.h #ifdef DEBUG static const int ddLogLevel = LOG_LEVEL_VERBOSE; #else static const int ddLogLevel = LOG_LEVEL_OFF; #endif框架
在xxx-Prefix.pch中添加Common.h的引入 #import "Common.h"测试
实例化DDLog 在- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions插件
方法中设置DDLogcode
// 实例化 lumberjack [DDLog addLogger:[DDTTYLogger sharedInstance]]; // 容许颜色 [[DDTTYLogger sharedInstance] setColorsEnabled:YES]; 使用方法 lumberjack提供了四种Log方法ip
DDLogError(@"错误信息"); // 红色 DDLogWarn(@"警告"); // 橙色 DDLogInfo(@"提示信息"); // 默认是黑色 DDLogVerbose(@"详细信息"); // 默认是黑色开发
其余 若是要修改Log输出的颜色可使用以下代码:get
[[DDTTYLogger sharedInstance] setForegroundColor:[UIColor blueColor] backgroundColor:nil forFlag:LOG_FLAG_INFO];
此文转载自:趣味苹果开发 欢迎访问本人技术微博 趣味苹果开发 相互交流,共同进步! 欢迎访问本人新浪微博 可可爸刘凡http://weibo.com/liufan2012