Last modified April 5, 2019 by Gordon Glauser

How do I configure SDK device logging?

By default, the Swrve SDK performs native device logging on iOS (Console Logs), Android (Logcat) and Unity. If required, you can disable these logs. On Android, you can also change the default logging level.

Additionally, the Swrve Unity SDK creates a small delay of approximately 14 milliseconds (ms) when logging. This is a not a big issue, however it can cause some performance implications if you’re firing events and your app operates at a high speed (for example, 60 frames per second, as you only have 16ms per frame). This article explains how to disable SDK device logs for iOS, Android and Unity.

iOS

If using source code

To disable the console logs on iOS, add a constant called SWRVE_DISABLE_LOGS to the preprocessor macros under App Target > Build Settings > Preprocessing > Preprocessor Macros.

If using CocoaPods

Add the following code to your podfile and reinstall the pod.

If using Carthage

In the SwrveFrameworks project in the Carthage/Checkouts/swrve-ios-sdk/SwrveFrameworks folder, add a constant called SWRVE_DISABLE_LOGS to the preprocessor macros, and then run a Carthage build to update your main project.

Android

You can disable the Logcat logs on Android via the configuration you use to create the Swrve instance. To disable the logs, call config.setLoggingEnabled(false) and include it in the SwrveSDK.createInstance method.

To change the logging level run the following adb command:

where <loglevel> is a value from 2 to 6.

For example, to change the logging level to DEBUG:

Log levels supported:

  • VERBOSE = 2
  • DEBUG = 3
  • INFO = 4
  • WARN = 5
  • ERROR = 6

To get the current logging level on a device, run the following adb command:

To use your own custom Timber Tree with Swrve and manage output to Logcat yourself, call SwrveLogger.useCustomLogger(true) so the SwrveLogger Tree does not get planted. This means you will see all Swrve logging regardless of log level for SwrveSDK. You can filter these by implementing Timber.Tree.isLoggable(String tag, int priority). For example, the code below filters out all Swrve logging less than WARNING level:

Unity

This log does not affect release builds. To disable the Swrve SDK logging in your app, set the logging level to disabled.