25

I am wondering.. Restkit keeps showing reachability information, request information as i use it. Will this automatically stop in production version or do i need to do something to stop them from displaying like setting RKLog level?

thanks

Glauco Neves
  • 3,483
  • 1
  • 24
  • 36
Veeru
  • 4,936
  • 2
  • 43
  • 61

5 Answers5

39

To turn everything off add this to your app delegate.

RKLogConfigureByName("*", RKLogLevelOff);

Note: At least in RestKit v0.20.x you will still see a "RestKit logging initialized..." message in dev builds.

Kyle Clegg
  • 38,547
  • 26
  • 130
  • 141
13

To suppress just the Reachability messages, use this:

RKLogConfigureByName("RestKit/Network/Reachability", RKLogLevelCritical);

Look in lcl_config_components.h for the complete list:

 "restkit"                           "RestKit" 
 "restkit.network"                   "RestKit/Network" 
 "restkit.network.cache"             "RestKit/Network/Cache" 
 "restkit.network.queue"             "RestKit/Network/Queue" 
 "restkit.network.reachability"      "RestKit/Network/Reachability" 
 "restkit.object_mapping"            "RestKit/ObjectMapping" 
 "restkit.core_data"                 "RestKit/CoreData" 
 "restkit.core_data.cache"           "RestKit/CoreData/Cache" 
 "restkit.core_data.search_engine"   "RestKit/CoreData/SearchEngine" 
 "restkit.support"                   "RestKit/Support" 
 "restkit.support.parsers"           "RestKit/Support/Parsers" 
 "restkit.three20"                   "RestKit/Three20" 
 "restkit.ui"                        "RestKit/UI" 
 "restkit.testing"                   "RestKit/Testing" 
 "app"                               "App" 
jpalten
  • 533
  • 4
  • 8
  • I wanted to point out that one can use RKLogDebug for their app by adding RKLogConfigureByName("App", RKLogLevelDebug); It took me a while to figure out that this line was needed to use RestKit's logging for my app. – pshah Aug 17 '12 at 19:24
12

The logging messages in a RestKit app are controlled by the RKLog calls. For example:

    RKLogConfigureByName("RestKit", RKLogLevelWarning); 
    RKLogConfigureByName("RestKit/ObjectMapping", RKLogLevelTrace);
    RKLogConfigureByName("RestKit/Network", RKLogLevelTrace);

RKLog is implemented with Aren Harren's lcl_log (see http://0xc0.de/LibComponentLogging) library. I just briefly looked through the code for lcl and I didn't see any code that would prevent it from printing in a production version, so I would ensure that my RKLog code does not appear in production code.

Paul Cezanne
  • 8,629
  • 7
  • 59
  • 90
  • So does that mean i dont have to worry about it? Will it be removed in production? I dont want my app to be rejected cause of having debug messages :) – Veeru Jun 08 '12 at 17:56
  • Sorry if I wasn't clear. I didn't see ANY mechanism for preventing logging, so I think you DO need to remove it. I was a bit surprised by this. I can't test this out, my RestKit app is not yet in the app store. – Paul Cezanne Jun 08 '12 at 18:38
  • RestKit logging explained here http://restkit-tutorials.com/logging-in-restkit-debug-tips/ – Alex Kurkin Jan 02 '14 at 11:09
8

RestKit is configured to show info messages and above in DEBUG builds. In non-DEBUG builds, only warnings, errors, and critical messages are logged. This is defined via RKLogLevelDefault in RKLog.h.

If you want to change the log level for one of RestKit's log components, you can call RKLogConfigureByName(component, level) with the component name and RKLogLevel log level. RKLogConfigureByName("*", RKLogLevelOff) can be used to disable logging for all components. Ensure that RKLogInitialize() was called before, because RKLogInitialize() overwrites the log level settings for RestKit's components on the first call.

If you want to remove all logging code from your production build, you can simply add the preprocessor define _LCL_NO_LOGGING to your build settings. See http://0xc0.de/LibComponentLogging for details.

Arne Harren
  • 166
  • 2
4

Kyle's solution is correct. The Swift version is a little bit different:

 RKlcl_configure_by_name("*", RKlcl_vOff.rawValue)
Enrico Susatyo
  • 19,372
  • 18
  • 95
  • 156