Hi,
I use NSLog in my application. And I'd like to get rid of the annoying beginning of each string: "2009-07-01 21:11:06.508 MyApp[1191:207]".
Is there a way to do so? Probably another logging function?
Thanks.
Hi,
I use NSLog in my application. And I'd like to get rid of the annoying beginning of each string: "2009-07-01 21:11:06.508 MyApp[1191:207]".
Is there a way to do so? Probably another logging function?
Thanks.
You could print to sdterr:
fprintf(stderr, "%s", "Your message");
Edit: Check out this implementation by Karl Kraft
Read this: http://cocoaheads.byu.edu/wiki/different-nslog
It's a wiki page on our CocoaHeads site that explains how to create a "QuietLog" function that does what you're describing. It also shows how to wrap QuietLog into a macro called LocationLog so that it'll print out the file name and line number where you've got the log statement. I use it in all of my projects, and I don't lose stray "NSLog" statements anymore.
I like being able to use objective-C objects for format strings and arguments, so I re-wrote NSLog() and added it to my utilities.
+ (void)myLog:(NSString *)formatString, ...
{
va_list args;
va_start(args, formatString);
NSString* output = [[NSString alloc] initWithFormat:formatString arguments:args];
fprintf(stderr, "%s\n", [output UTF8String]);
[output release];
va_end(args);
}
Sorry, unable to comment on original answer above..
The Cocoa Heads link is broken.
Use http://cocoaheads.byu.edu/wiki/different-nslog to find the wiki page.