Logging NSLog meta data
suggest changeNSLog(@"%s %d %s, yourVariable: %@", __FILE__, __LINE__, __PRETTY_FUNCTION__, yourVariable);
Will log the file, line number and function data along with any variables you want to log. This can make the log lines much longer, particularly with verbose file and method names, however it can help to speed up error diagnostics.
You can also wrap this in a macro. Put it in a header you import where you log:
#define ALog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
Then when you want to log, simply call
ALog(@"name: %@", firstName);
That produces a line like:
-[AppDelegate application:didFinishLaunchingWithOptions:] [Line 27] name: John
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents