美文网首页
ios 完美解决Xcode NSLog打印不全的宏

ios 完美解决Xcode NSLog打印不全的宏

作者: 缘來諟夢 | 来源:发表于2020-09-27 09:14 被阅读0次
/**
*  完美解决Xcode NSLog打印不全的宏
*/
#ifdef DEBUG
#define HKLog(FORMAT, ...) {\
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];\
[dateFormatter setDateStyle:NSDateFormatterMediumStyle];\
[dateFormatter setTimeStyle:NSDateFormatterShortStyle];\
NSTimeZone* timeZone = [NSTimeZone timeZoneWithName:@"Asia/Beijing"];\
[dateFormatter setTimeZone:timeZone];\
[dateFormatter setDateFormat:@"HH:mm:ss.SSSSSSZ"];\
NSString *str = [dateFormatter stringFromDate:[NSDate date]];\
fprintf(stderr,"--TIME:%s【FILE:%s--LINE:%d】FUNCTION:%s\n%s\n",[str UTF8String],[[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__,__PRETTY_FUNCTION__,[[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);\
}
#else
# define HKLog(...);
#endif

相关文章

网友评论

      本文标题:ios 完美解决Xcode NSLog打印不全的宏

      本文链接:https://www.haomeiwen.com/subject/mfekuktx.html