Debugging
Debugging
VGSShowSDK
provides customizable configuration to debug and log potential issues. By default all logging options are disabled.
VGSShowSDK
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 errros by changing VGSLogger.shared
instance configuration.level
property. You can also turn on isNetworkDebugEnabled
property for logging VGSShowSDK
network requests to verify whether request was successfull or failed.
// Log only warnings and errors.
VGSLogger.shared.configuration.level = .warning
// Log network requests.
VGSLogger.shared.configuration.isNetworkDebugEnabled = true
You may always debug your setup with Access Logger, by seeing requests statuses, payload diffs, matched information etc.
Log levels
VGSShowSDK
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 VGSLogger.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.
VGSLogger.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.
VGSLogger.shared.configuration.level = .info
// Log network requests.
VGSLogger.shared.configuration.isNetworkDebugEnabled = true
// Add verbose information to logs.
VGSLogger.shared.configuration.isExtensiveDebugEnabled = true
Errors Handling
This guide covers error handling features which will help you to make your App more reliable and recover from errors produced by VGSShowSDK
.
VGSShowError
An object VGSShowSDK
use to produce errors inside the SDK. All VGSShowSDK
errors are produced under VGSShowSDKErrorDomain
domain.
Declaration
class VGSShowError: NSError
Attributes
Attribute
Type/Description
key
String, error key defined in VGSErrorInfoKey.swift
NSLocalizedDescriptionKey
String, error description for developer
extraInfo
Dictionary, can contain additional error details
VGSShowError
inherits iOS native NSError
class and works similar. VGSShowError
populates error codes, declared in VGSErrorType
, and error keys, declared in VGSShowSDK Reference docs.
Error codes
List of Error codes produced by VGS Show iOS SDK locally.
Code
Key
Description
1400
unexpectedResponseType
When response type is not supported
1401
unexpectedResponseDataFormat
When response data format is not supported
1402
responseIsInvalidJSON
When response cannot be decoded to json
1403
fieldNotFound
When field cannot be found with specified path
1404
invalidJSONPayload
When payload is invalid JSON
1405
invalidBase64Data
When base64 data is invalid
1406
invalidPDFData
When PDF data is invalid
1480
invalidConfigurationURL
When VGS configuration URL is not valid
Code example
vgsShow.request(path: "/post",
payload: data) { (requestResult) in
switch requestResult {
case .failure(let code, let error):
switch code {
/// response type error
case VGSErrorType.unexpectedResponseType.rawValue:
/// handle error
/// ...
}
}
}
Last updated