In Xcode, is there a way to disable the timestamps that appear in the debugger console when calling NSLog?

前端 未结 8 2297
别跟我提以往
别跟我提以往 2020-12-02 14:30

Xcode\'s debugger console makes it easy to see any debugging messages my app sends out using NSLog(), but it always sticks a timestamp prefix on them:



        
8条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-02 15:13

    This is way more easier than the suggested solutions. Using carelesslyChoosy's solution and adding a little bit more to make it log entries on release builds only you get the macro below. Just add this macro to your header or .pch file. This macro will show log entries when the DEBUG flag is enabled, on release builds you won't see log entries.

    #ifdef DEBUG
    #define NSLog(FORMAT, ...) printf("%s\n", [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);
    #define Log(x, ...) NSLog(@"%s %d: " x, __FUNCTION__, __LINE__, ##__VA_ARGS__)
    #else
    #define Log(x, ...)
    #endif
    

提交回复
热议问题