1. In the general project my NSLog will add the following code in the Prefix.pch file, which is guaranteed nslog not working in the non-debug state
| 12345 |
#ifdef debug#define NSLog (...) NSLog (__va_args__) #else # define NSLOG (...) #endif |
2. If you do not do any processing in the project, the following information will be output, preceded by a timestamp
| 1 |
2014-11-07 08:25:40.885 zcsy[673:8937] cell height 258.684998 |
We modified the following macro as follows:
| 12345 |
#ifdef debug#define NSLog (FORMAT, ...) fprintf (stderr, "%s\n", [[NSString Stringwithformat:format, # #__VA_ARGS__] Utf8string]); #else # define NSLOG (...) #endif |
After the above changes we can output pure content as follows:
| 1 |
Cell's Height 258.684998 |
We can use the better version I recommend to print our log:
| 12345 |
#ifdef debug#define NSLog (FORMAT, ...) fprintf (stderr, "%s:%d\t%s\n", [[[NSString stringwithutf8string:__file__] Lastpathcomponent] utf8string], __line__, [[NSString Stringwithformat:format, # #__VA_ARGS__] utf8string]); #else # Define NSLOG (...) #endif |
So our output is this:
| 12 |
It will output the filename, and print the exact line number dealitemcell.m:307 cell's height 258.684998 |
http://www.guoms.com/?p=124
IOS NSLog removing timestamps and other output styles