Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restkit, Stop Logging?

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

like image 225
Veeru Avatar asked Jun 08 '12 07:06

Veeru


5 Answers

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.

like image 170
Kyle Clegg Avatar answered Nov 16 '22 06:11

Kyle Clegg


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" 
like image 39
jpalten Avatar answered Nov 16 '22 05:11

jpalten


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.

like image 42
Paul Cezanne Avatar answered Nov 16 '22 06:11

Paul Cezanne


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.

like image 35
Arne Harren Avatar answered Nov 16 '22 07:11

Arne Harren


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

 RKlcl_configure_by_name("*", RKlcl_vOff.rawValue)
like image 4
Enrico Susatyo Avatar answered Nov 16 '22 07:11

Enrico Susatyo