Debugging

VGSCollectSDK provides customizable configuration to debug and log potential issues. By default all logging options are disabled.

VGSCollectSDK only prints formatted logs to your console. It does not record your activity to some persistent storage, local file, also we do not send your logging activity to any server.

You can turn on logging warnings and erros by changing VGSCollectLogger.shared instance configuration.level property. You can also turn on isNetworkDebugEnabled property for logging VGSCollectSDK network requests to verify whether request was successfull or failed.

// Log only warnings and errors.
VGSCollectLogger.shared.configuration.level = .warning

// Log network requests.
VGSCollectLogger.shared.configuration.isNetworkDebugEnabled = true

You may always debug your setup with Access Logger, by seeing requests statuses, payload diffs, matched information etc.

Log levels

VGSCollectSDK provides the following log levels:

  • info. Log all events including errors and warnings.

  • warning. Log only events indicating warnings and errors.

  • none. Log no events. Default setting.

/// Defines levels of logging.
public enum VGSLogLevel: String {
	/// Log *all* events including errors and warnings.
	case info

	/// Log *only* events indicating warnings and errors.
	case warning

	/// Log *no* events.
	case none
}

Disable logging

To disable all logging activities you can use disableAllLoggers() method of VGSCollectLogger.shared instance. It will set log level to .none and stop network debugging.

if MyApp.shared.configuration == .prod {
    // Disable all loggers for your prod configuration and live apps.
	VGSCollectLogger.shared.disableAllLoggers()
}

You should NOT use logging in your production configurations for live applications.\

Extensive logging

For extensive debugging and logging you can set log level to .info and .isExtensiveDebugEnabled option to true. You can turn on .isExtensiveDebugEnabled option for more verbose logs like file name, function name and line number where event was trigerred.

// Log all events.
VGSCollectLogger.shared.configuration.level = .info

// Log network requests.
VGSCollectLogger.shared.configuration.isNetworkDebugEnabled = true

// Add verbose information to logs.
VGSCollectLogger.shared.configuration.isExtensiveDebugEnabled = true

Last updated