一、封装带颜色的日志
-
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(@"与主机连接成功");
网友评论