Debugging and Logs

Troubleshoot your implementation of the iOS SDK and help OpenWeb improve the quality of the product.

Without impacting the performance of your app, the iOS SDK logging system can help you troubleshoot your implementation of the iOS SDK and help OpenWeb improve the quality of the product.

As a troubleshooting tool, the iOS log files offer the following benefits:

  • Viewing logs in the console
  • Saving logs locally in the application's Document directory
  • Generating logs that can be submitted with a support ticket when issues are hard to reproduce

As an improvement tool, the iOS log files help OpenWeb to make the SDK more stable.

As for the performance of your app, the logging system has minimal impact:

  • Log files are created in the OpenWebSDKLoggerFileCreationQueue queue with a .background priority.
  • All other logging functions are performed in the OpenWebSDKLoggerQueue background queue with a .utility priority.

📘

No logs are sent to OpenWeb's backend servers.



Configure logging settings

🚧

When you configure the logger, OpenWeb disregards any pending logs. OpenWeb will not create files for these logs.

We strongly recommend configuring the logger after the initialization method. This ensures that files will be created for any pending logs.


By default, OpenWeb initializes the logger with the following settings:

  • logLevel: .verbose
  • logMethods: [.nsLog, .file(maxFilesNumber: 20)]

If you want to configure these default logging settings, you can call the following method.

SpotIm.configureLogger(logLevel: SPLogLevel, logMethods: [SPLogMethod])

SPLogLevel

Option Description Debug Symbol
none No logged items -n
error Logged items:
  • Errors
-e
medium Logged items:
  • Errors
  • General information
-m
verbose Logged items:
  • Errors
  • General information
  • Any other available information
-v

SPLogMethod

While the following options can all be used together, we recommend using one of the following combinations:

  • [.nsLog, file(maxFilesNumber: Int)]
  • [.osLog, file(maxFilesNumber: Int)]
Option Description
nsLog Apple NSLog
osLog Preferred Apple OSLog framework
file(maxFilesNumber: Int) Defines the maximum number of log files that will be created and stored in your application's Documents directory

maxFilesNumber: Maximum number log files that are stored locally

The maxFilesNumber must be a number within the following range: 1-200. If the value passed is outside of this range, the default value of 20 will be used.

NSLog

The following screenshots show the Xcode debugger console and device logs when using the NSLog framework.

1000

Xcode debugger console

1156

Device logs


OSLog

The following screenshots show the Xcode debugger console and device logs when using Apple's preferred OSLog framework.

1000

Xcode debugger console

1156

Device logs


Files

This option defines the maximum number of log files that will be created and stored in your application's Documents directory. After exceeding this number, the logger will remove the oldest log file when creating a new log file.

The logger will create a file in either of the following conditions:

  • There are 100 items* to log.

    * An item is each message logged by OpenWeb, such as a simple line or full information about a network request. The SPLogLevel affects the data within each item and if the item is logged. Based on testing, logLevel: .verbose will not generate log files that exceed 1.5MB.

  • The application has moved to the background.

The following screenshots are examples from inside a simulator directory.

1492

Simulator directory

1217

Log file



Disable logging

Log files can be an essential debugging tool. At minimum, we recommend enabling log files in your debug environment.

If you need to disable logging, you can call the following method.

SpotIm.configureLogger(logLevel: .none , logMethods: [])