xcode Log 插件

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碼


參考使用

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容