ios - NSLog disable from certain classes and DEBUG -
hello guys have found code used create different nslog (without data , timestamps) displays class log made , line number. have read possible disable logging classes no_log there not explained how use exactly, quite new obj-c , appreciate explanation on how disable logging classes , how activate , deactivate debugging. thanks
#define makestring(__va_args__) #__va_args__ #define tostring(...) makestring(__va_args__) static inline void pxreportv(bool dolog, char const *file, int line, nsstring *prefix, nsstring *fmt, va_list arglist) { if (dolog) { nsstring *filenamewithextension = [[nsstring stringwithformat:@"%s", file] lastpathcomponent]; #ifdef no_log nsstring *filename = [filenamewithextension stringbydeletingpathextension]; char *f = tostring(no_log); nsarray *comps = [[[nsstring alloc] initwithformat:@"%s", f] componentsseparatedbystring:@","]; (nsstring *except in comps) { if ([except isequaltostring:filename]) { return; } } #endif vprintf([[[nsstring alloc] initwithformat:[[nsstring alloc] initwithformat:@"%@ <%@ [%d]> %@\n", prefix, filenamewithextension, line, fmt] arguments:arglist] cstringusingencoding:nsutf8stringencoding], null); } } static inline void pxreport(bool dolog, char const *file, int line, nsstring *prefix, nsstring *fmt, ...) { va_list ap; va_start(ap, fmt); pxreportv(dolog, file, line, prefix, fmt, ap); va_end(ap); } #define pxerror(...) pxreport(yes, __file__, __line__, @"[error]", __va_args__) #ifdef debug #define pxdebug(...) pxreport(yes, __file__, __line__, @"[debug]", __va_args__) #define nslog(...) pxreport(yes, __file__, __line__, @"", __va_args__) #else #define pxdebug(...) #define nslog(...) #endif
add this:
#define no_log 1
before #import
ing file you've shown above.
btw better implementation define pxdebug()
, nslog()
nothing if no_log
defined...
Comments
Post a Comment