iOS 帶顏色的日志

一、封裝帶顏色的日志

  • 1、利用XMPPFrame框架中的來封裝

  • 2、創建一個類:JPColorLog

    • 2.1 JPColorLog.h文件
#import <Foundation/Foundation.h>
#import "DDLog.h"
#import "DDTTYLogger.h"
#import "DDFileLogger.h"
#import "MBProgressHUD+JP.h"

#ifdef DEBUG
static const int ddLogLevel = LOG_LEVEL_VERBOSE;
#else
static const int ddLogLevel = LOG_LEVEL_OFF;
#endif

#define classmethod [NSString stringWithFormat:@"[%@ %@] \n",self.class,NSStringFromSelector(_cmd)]


//#define JPLogError(...) DDLogError(__VA_ARGS__)

//錯誤級別
#define JPLogError(...) DDLogError(@"%@ %@\n",classmethod,[NSString stringWithFormat:__VA_ARGS__])

//警告級別
#define JPLogWarn(...) DDLogWarn(@"%@ %@\n",classmethod,[NSString stringWithFormat:__VA_ARGS__])

//提示級別
#define JPLogInfo(...) DDLogInfo(@"%@ %@\n",classmethod,[NSString stringWithFormat:__VA_ARGS__])

//詳情級別
#define JPLogVerbose(...) DDLogVerbose(@"%@ %@\n",classmethod,[NSString stringWithFormat:__VA_ARGS__])

@interface JPColorLog : NSObject

@end
  • 2.2、將頭文件寫入到pch文件中
#ifdef __OBJC__
   #import <UIKit/UIKit.h>
   #import <Foundation/Foundation.h>
   #import "JPColorLog.h" // 導入帶顏色日志
#endif
  • 2.3 使用帶顏色的日志輸出

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

推薦閱讀更多精彩內容

  • 1,NSObject中description屬性的意義,它可以重寫嗎?答案:每當 NSLog(@"")函數中出現 ...
    eightzg閱讀 4,192評論 2 19
  • 1.項目經驗 2.基礎問題 3.指南認識 4.解決思路 ios開發三大塊: 1.Oc基礎 2.CocoaTouch...
    陽光的大男孩兒閱讀 5,042評論 0 13
  • 轉載自:這里 #######宏定義在很多方面都會使用,例如定義高度、判斷iOS系統、工具類,還有諸如文件路徑、服務...
    LiWonderfull閱讀 782評論 0 2
  • 讀入圖像后,獲得像素RGB值,修改后保存為新的文件
    夏天才愛睡覺閱讀 321評論 0 0
  • 彼時,誓死白頭。 恍然,大們初醒。 此時,婚衣滿地。 一切,相思風雨。 唯有,語不言盡。 祝愿,安好若世。
    22a95a080ef5閱讀 121評論 0 0