我目前正在使用此处所示的“灵活日志记录” ,例如:
LogInfo(@"Do you object to this %@ date object?", [NSDate new]);
LogDebug(@"I'll take this out if ever I solve this bug");
LogError(@"Don't do that: %@", [NSException exceptionWithName: @"CRYING" reason: @"Spilled milk" userInfo:nil]);
我现在已将 Crashlytics 库添加到我的项目中,并将其添加到 Prefix.pch:
#ifdef DEBUG
#define CLS_LOG(__FORMAT__, ...) CLSNSLog((@"%s line %d $ " __FORMAT__), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#else
#define CLS_LOG(__FORMAT__, ...) CLSLog((@"%s line %d $ " __FORMAT__), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#endif
有没有办法将所有日志消息从 LogInfo、LogDebug、LogError 等重定向到 CLS_LOG?
我为 TestFlight 做了这个:
#define NSLog TFLog
但是对 Crashlytics 做同样的事情是行不通的,并且会给出关于重新定义宏的警告:
#define LogDebug CLS_LOG