The following macros are briefly introduced:
1) _ va_args _ is a macro of a variable parameter. The macro of this variable parameter is added in the new c99 specification, currently, only GCC is supported (not supported by the vc6.0 compiler ). # Is added before the Macro. When the number of variable parameters is 0, # is used to remove ",". Otherwise, compilation errors may occur.
2) _ file _ Macro will be replaced with the current source file name during pre-compilation.
3) _ line _ Macro will be replaced with the current row number during pre-compilation.
4) _ function _ macro is replaced with the current function name during pre-compilation.
1. Redefine the nslog of the system,_ Optimize _ is the macro added by default to release.
# Ifndef _ optimize __# define nslog (...) nslog (_ va_args _) # else # define nslog (...) {}# endif
2. Write # define directly. When the release version is released, comment out # define.
# Define ios_debug
# Ifdef ios_debug # define nslog (...) nslog (_ va_args _) # endif
3.
# Ifdef debug # define dlog (format ,...) nslog (@ "[File Name: % s]" "[function name: % s]" "[line number: % d]" format), _ file __, _ FUNCTION __, _ line __, ##__ va_args _); # else # define dlog (...); # endif
This method requiresModify the configuration of the project so that dlog macros are compiled during debug compilation to generate detailed log information. In release, no console output is generated.
, the first one is more convenient