#define DebugLogEnable 1
#if DebugLogEnable
#define macro_to_str1(x) #x
#define macro_to_str(x) macro_to_str1(x)
#define DebugString(format,...) ([NSString stringWithFormat: @" %s %@ ", __FUNCTION__, [NSString stringWithFormat:format, ##__VA_ARGS__]])
#define xsyLog(format, ...) NSLog(@"%@",DebugString(format, ##__VA_ARGS__))
#define xsyLogError(error) xsyLog(@"error:%@",error)
#define xsyLogMethod() xsyLog(@"")
#else
#define DebugString(format,...) @""
#define xsyLog(format, ...)
#define xsyLogError(error)
#define xsyLogMethod()
#define NSLog(...)
#endif
本文介绍了如何自定义一个打印宏,包括DebugLogEnable开关、宏展开转换字符串、NSLog结合方法调用等,用于在开发中方便地输出调试信息。
1183

被折叠的 条评论
为什么被折叠?



