IOS NSLog removing timestamps and other output styles

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.