Objective C macro - logging wrapper
As we know logging in Objective C is using NSLog
. The problem here
is I want to enable & disable the logging by changing a flag, NOT
remove NSLog
when don’t want to see the log; add NSLog
when want to
see the log.
There is a solution, which is CocoaLumberjack. However, I just want to see the message in console,
don’t want such a huch package.
Thus I choose to use macro.
Let’s add the macro in Prefix.pch
1 | ... |
- I can now turn on or off (by changing the value to
YES
orNO
) at anytime - The usage is exactly same as
NSLog
. e.g.JSLog(@"error %@", error);