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

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


NSLog() is what is doing that, not the debugger console.

The easiest way to avoid it is to not use NSLog at all. You could use fprintf(), but that is a pain in that it doesn't support %@ format types.

I generally write a function for this:

void MyLog(NSString *format, ...) {    va_list args;    va_start(args, format);    NSString *formattedString = [[NSString alloc] initWithFormat: format                                                  arguments: args];    va_end(args);    [[NSFileHandle fileHandleWithStandardOutput]        writeData: [formattedString dataUsingEncoding: NSNEXTSTEPStringEncoding]];}

Obviously, modify it to add a newline or use a shorter prefix, etc...

(Fixed the stray ctrl-b)


Define a macro

#if __has_feature(objc_arc)  #define MDLog(format, ...) CFShow((__bridge CFStringRef)[NSString stringWithFormat:format, ## __VA_ARGS__]);#else  #define MDLog(format, ...) CFShow([NSString stringWithFormat:format, ## __VA_ARGS__]);#endif

And use this macro in you code like

NSLog(@"some log message");MDLog(@"some log message");

Here is the output of console

NSLog->2014-01-28 10:43:17.873 TestApp[452:60b] some log message
MDLog -> some log message


P.S.

If anyone wants Custom Logs which gives you more info like method name / line number etc. can download the open source MLog.h on GitHub.


put in this one line code in your .pch file and you are done

#define NSLog(FORMAT, ...) printf("%s\n", [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);

notice the ## part