xcode Log 插件

2016-08-18  本文已影响0人  LHKevin

1. 安装XcodeColors插件

2、下载CocoaLumberjack开源框架

3、使用

#ifdef DEBUG

static const int ddLogLevel = LOG_LEVEL_VERBOSE;

#else

static const int ddLogLevel = LOG_LEVEL_OFF;

#endif

setenv("XcodeColors", "YES", 0);

// 实例化 lumberjack

[DDLog addLogger:[DDTTYLogger sharedInstance]];

// 允许颜色

[[DDTTYLogger sharedInstance] setColorsEnabled:YES];

lumberjack提供了四种Log方法

DDLogError(@"错误信息"); // 红色

DDLogWarn(@"警告"); // 橙色

DDLogInfo(@"提示信息"); // 默认是黑色

DDLogVerbose(@"详细信息"); // 默认是黑色

其他

如果要修改Log输出的颜色可以使用如下代码:

[[DDTTYLogger sharedInstance] setForegroundColor:[UIColor blueColor] backgroundColor:nil forFlag:LOG_FLAG_INFO];

插件目录看:

sudo open /Users/你的用户名/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins

打开终端,输入以下代码:

defaults read /Applications/Xcode.app/Contents/Info DVTPlugInCompatibilityUUID

获取到DVTPlugInCompatibilityUUID,然后

$ find ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins -name Info.plist -maxdepth 3 | xargs -I{} defaults write {} DVTPlugInCompatibilityUUIDs -array-add UUID码

参考使用

上一篇 下一篇

猜你喜欢

热点阅读