QLog()

This Snippet is an alternative to NSLog. NSLog is great for occasional logging of debug and status message. It can however be a bit verbose because it includes the timestamp, process name, and process id on every line. If you are writing a command line tool this is overkill.QLog removes all this extra information and just prints the passed string and arguments.


// Example
NSLog(@"Starting %d",1);
// 2007-06-26 01:39:35.629 MyGreatApp[3106:813] Starting 1
QLog(@"Starting %d",1);
// Starting 1

As a bonus you can also redirect the output of QLog to a file by using setDebugOutputPath()

void setDebugOutputPath(NSString *filePath)

Note that filePath is not overwritten but rather appends new debug lines.

This entry was posted in TheCodeBook - Snippets. Bookmark the permalink. Follow any comments here with the RSS feed for this post. Both comments and trackbacks are currently closed.
  • iChat Status