前言:很多小伙伴把Xcode升级到Xcode8之后会发现无缘无故打印很多系统日志并打印不全。
1、屏蔽系统日志
Xcode -- Product -- Scheme -- Edit Scheme -- Run -- Environment Variables 中添加 OS_ACTIVITY_MODE为disable
进入快捷键:command + < 或 (command + shift + ,)
2、打印不全
//2.日志输出宏定义
#ifdef DEBUG
//调试状态
#define MyString [NSString stringWithFormat:@"%s", __FILE__].lastPathComponent
#define MyLog(...) printf("%s: %s 第%d行: %s\n\n",[[IWCommon getCurrentDate] UTF8String], [MyString UTF8String] ,__LINE__, [[NSString stringWithFormat:__VA_ARGS__] UTF8String]);
#else
//发布状态
#define MyLog(...)
#endif
#pragma mark 获取当前时间
+ (NSString *)getCurrentDate
{
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"YYYY-MM-dd hh:mm:ss"];
NSString *dateString = [dateFormatter stringFromDate:[NSDate date]];
return dateString;
}