I'm trying to debug RestKit object mapping and noticed that there are calls to RKLogDebug
throughout the code, but it appears that that macro is undefined somewhere. How can I enable it?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You want to add something like this:
RKLogConfigureByName("RestKit", RKLogLevelWarning);
RKLogConfigureByName("RestKit/ObjectMapping", RKLogLevelTrace);
RKLogConfigureByName("RestKit/Network", RKLogLevelTrace);
to your code. See RKLog.h for the various levels. It is pretty trick.
N.B. this supports a wildcard at the end so, e.g.,
RKLogConfigureByName("*", RKLogLevelTrace); // set all logs to trace,
RKLogConfigureByName("RestKit*", RKLogLevelWarning); // set all RestKit logs to warning (leaving the app-specific log untouched).
– Thanks Kevin!
回答2:
As described in first answer you can configure your app to specific component by calling RKLogConfigureByName
.
You can also configure RestKit for specific component using Environment Variables in Xcode scheme. This is useful especially when you have your app building continuously for different environments.
Here's detailed explanation of RestKit logging http://restkit-tutorials.com/logging-in-restkit-debug-tips/