//打印
#if DEBUG
#define DEBUGLOG(format, ...) do {\
fprintf(stderr, "-----------------------------------------\n"); \
fprintf(stderr, "File: %s\nFunc: %s\nLine: %d / Time: [%s]\n", \
[[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], \
__func__, __LINE__, __TIME__); \
fprintf(stderr, "Format:\n %s \n", \
[[NSString stringWithFormat:format, ##__VA_ARGS__] UTF8String]); \
fprintf(stderr, "-----------------------------------------\n\n"); \
} while (0)
#define _po(o) DEBUGLOG(@"%@", (o))
#define _pn(o) DEBUGLOG(@"%d", (o))
#define _pf(o) DEBUGLOG(@"%f", (o))
#define _ps(o) DEBUGLOG(@"CGSize: {%.0f, %.0f}", (o).width, (o).height)
#define _pr(o) DEBUGLOG(@"CGRect: {{%.0f, %.0f}, {%.0f, %.0f}}", (o).origin.x, (o).origin.y, (o).size.width, (o).size.height)
#define OBJ(obj) DEBUGLOG(@"%s: %@", #obj, [(obj) description])
#define MARK DEBUGLOG(@"\nMARK: %s, %d", __PRETTY_FUNCTION__, __LINE__)
#else
#define DEBUGLOG(format, ...) nil
#endif
网友评论