Ir para o conteúdo principal
Adaptive Planning
ai.log

ai.log

Functions

Method
Parameters
Return Type
Description
logError( summary, detail )
summary : Mixed Log summary text
detail : Mixed Optional - further detail about log
Boolean
Adds an event log with an ERROR log level. 'summary' is truncated at 128 characters. 'detail' is truncated at 1000 characters. All non string values are converted to strings. Log entry is added if the logging thresholds have not been breached. Returns true if logging was successful.
logInfo( summary, detail )
summary : Mixed Log summary text
detail : Mixed Optional - further detail about log
Boolean
Adds an event log with an INFO log level. 'summary' is truncated at 128 characters. 'detail' is truncated at 1000 characters. All non string values are converted to strings. Log entry is added if the logging thresholds have not been breached. Returns true if logging was successful.
logVerbose( summary, detail )
summary : Mixed Log summary text
detail : Mixed Optional - further detail about log
Boolean
Adds an event log with an INFO log level. 'summary' is truncated at 128 characters. 'detail' is truncated at 1000 characters. All non string values are converted to strings. Log entry is added if the logging thresholds have not been breached. Returns true if logging was successful.

Example

function testConnection(context) { // Step 1: Create a https request to send to Earthquake USGS API var url = 'https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_hour.atom'; var method = 'GET'; var body = ``; var headers = {}; // Step 2: Send request and receive response try{ var response = ai.https.request(url, method, body, headers); //Example logInfo ai.log.logInfo("Test Connection Successful"); //Test Connection Successful //Example logVerbose ai.log.logVerbose("Test Connection Successful", response.getBody()); //Test Connection Successful //2020-10-23T00:25:21ZU.S. Geological Surveyhttps://earthquake.usgs.gov/https://........ } catch(e) { //Example for logError ai.log.logError("Test Connection Failed"); } // Step 3: Interrogate response to see if it was successful. Return true or false depending on the result. if (response.getHttpCode() == '200') { var body = response.getBody(); return true; } else { return false; } }
Log throttling (burst + sustained) ensures any given script cannot:
  • write more than X logs per second (Burst: default is 5, configurable as AppSetting or per tenant)
  • write more than X logs per hour (Sustained: default is 1000, configurable as AppSetting or per tenant)