Search code examples
iphoneiosobjective-cnslogtestflight

How to copy existing app logs to TestFlight and using macros


I am currently integrating the test flight SDK. Currently I have a macro for logging called DebugLog:

#ifdef DEBUG
    #define DebugLog(s,...) NSLog(@"Thread:%@  [%@ %@] %@", [[NSThread currentThread] name], NSStringFromClass([self class]), NSStringFromSelector(_cmd), [NSString stringWithFormat:s,##__VA_ARGS__])
#else
    #define DebugLog(s,...)
#endif

I now want to integrate Testflight's TFLog into our project:

#define NSLog(__FORMAT__, ...) TFLog((@"%s [Line %d] " __FORMAT__), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)

My question is, is there a way of redirecting the logging from DebugLog to TFLog i.e. DebugLog fires and logs to the console and it also logs to TFLog?


Solution

  • Use this one

    //Here I have added NSLog followed by TFLog
    #define DebugLog(s,...) NSLog(@"Thread:%@  [%@ %@] %@", [[NSThread currentThread] name], NSStringFromClass([self class]), NSStringFromSelector(_cmd), [NSString stringWithFormat:s,##__VA_ARGS__]);TFLog(s,##__VA_ARGS__)
    //You can use this within  #ifdef #endif construct