先上自定义宏
#ifdef DEBUG
# define DLog(fmt, ...) NSLog((@"[文件名:%s]\n" "[函数名:%s]\n" "[行号:%d] \n" fmt), __FILE__, __func__, __LINE__, ##__VA_ARGS__);
#else
# define DLog(...);
#endif
Description:
声明后 在函数内调用DLog(可加参数),可在运行时打印所在函数的相关信息。
Macro | Format Specifier | Description |
__func__ | %s | Current function signature. 当前函数名 |
__LINE__ | %d | Current line number in the source code file. 所在源码文件行号 |
__FILE__ | %s | Full path to the source code file. 源码文件全路径 |
__PRETTY_FUNCTION__ | %s | Like __func__, but includes verbose type information in C++ code. 详细函数名 |
__VA_ARGS__ 多参
##__VA_ARGS__ 参数为空自动去逗号