Use the SDK to create and save diagnostic logs

Note: This article applies to Genesys Cloud for Salesforce.

You can use our SDK in the managed package to generate diagnostic logs in Salesforce. The SDK uses the Salesforce Apex programming language. 

Note: This advanced customization article is intended for developers who are familiar with Salesforce.

Prerequisites

Access our SDK through the Logger class under the purecloud.SDK.Logger namespace.

Logger class

Contains methods that allow you to create and save diagnostic logs through Genesys Cloud for Salesforce.

Note: Due to Salesforce limitations, the integration stores a created log in memory until the end of a transaction with the createPendingLog method. At the end of a transaction, the integration saves these logs as log objects to your Salesforce organization with the savePendingLogs method.

Namespace

purecloud.SDK.Logger

Usage

Use these methods to create pending log requests and then save the logs at the end of a transaction through Genesys Cloud for Salesforce. 

Logger methods

The following methods are available for the Logger class.

Creates a pending log stored in memory for your Salesforce organization.

Parameters

Name Data type Description Notes
name String Name of the log that you want to appear in your Salesforce organization.
message String Message that you want to appear in the log.
logLevel purecloud.Log.LogLevels enum

Log level for the logs that you want to create.

 

Valid values: ERROR, WARN, INFO, DEBUG.

This log level must match or be lower than the log level that you set in Salesforce. For example, if you set Logging to WARN in the call center settings, then you must pass ERROR or WARN into logLevel in your Apex code; if you pass INFO or DEBUG, then the integration will not create logs. For more information, see Diagnostic logs in Salesforce.

Example

The following example creates a pending log in memory. The log request is called SDK, generates a message, and generates the most detailed amount of information (DEBUG).

purecloud.SDK.Logger.createPendingLog('SDK', 'I am a diagnostic log message!', purecloud.Log.LogLevels.DEBUG);

Saves pending logs stored in memory to your Salesforce organization. Uses DML to insert logs into Genesys Cloud_Log__c records.

The saved logs appear on the Genesys Cloud Logs page in Salesforce. For more information, see Diagnostic logs in Salesforce.

Example

The following example saves pending logs that were stored in memory with the createPendingLogs method. 

purecloud.SDK.Logger.savePendingLogs();

For more information, see SDK in Genesys Cloud for Salesforce.

For more information about the integration, see About Genesys Cloud for Salesforce.