重写NSLog,Debug模式下打印日志和当前行数

时间:2023-03-08 16:30:57
重写NSLog,Debug模式下打印日志和当前行数

在pch文件中加入以下命令,NSLog在真机测试中就不会打印了

//重写NSLog,Debug模式下打印日志和当前行数

#if DEBUG

#define NSLog(FORMAT, ...) fprintf(stderr,"\nfunction:%s line:%d content:%s\n", __FUNCTION__, __LINE__, [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);

#else

#define NSLog(FORMAT, ...) nil

#endif