src/index.js
/**
 * Transforms a CloudWatch message into a format appropriate for submitting to a Scalyr API endpoint (either uploadLogs
 * or addEvents). The endpoint used depends on the value of the USE_ADD_EVENTS_API environment variable, which should
 * be true or false. If this environment variable isn't specified, then the uploadLogs API will be used.
 *
 * @param {Object} cloudWatchMessage   Incoming CloudWatch message.
 * @returns {Object}          Outgoing Scalyr message.
 */
Transforms a CloudWatch message into a format appropriate for submitting to a Scalyr API endpoint (either uploadLogs
or addEvents). The endpoint used depends on the value of the USE_ADD_EVENTS_API environment variable, which should
be true or false. If this environment variable isn't specified, then the uploadLogs API will be used.


Transforms a CloudWatch message into a format appropriate for submitting to a Scalyr API endpoint ( either uploadLogs or addEvents ) . The endpoint used depends on the value of the USE_ADD_EVENTS_API environment variable which should be true or false . If this environment variable isn ' t specified then the uploadLogs API will be used .
function transformToPost(cloudWatchMessage) {
  if (useAddEventsApi) {
    return {
      headers: {'content-type': 'application/json'},
      url: addEventsUrl,
      body: JSON.stringify(transformToAddEventsMessage(cloudWatchMessage))
    };
  } else {
    const message = transformToUploadLogsMessage(cloudWatchMessage);
    return {
      headers: {'content-type': 'text/plain'},
      url: `${uploadLogsUrl}?token=${message.token}&host=${message.host}&logfile=${message.logfile}&server-logStream=${message.logStream}&parser=${defaultParserName}`,
      body: message.body
    };
  }
}
function transformToPost ( cloudWatchMessage ) { if ( useAddEventsApi ) { return { headers : { 'content-type' : 'application/json' } , url : addEventsUrl , body : JSON . stringify ( transformToAddEventsMessage ( cloudWatchMessage ) ) } ; } else { const message = transformToUploadLogsMessage ( cloudWatchMessage ) ; return { headers : { 'content-type' : 'text/plain' } , url : ` ${ uploadLogsUrl } ${ message . token } ${ message . host } ${ message . logfile } ${ message . logStream } ${ defaultParserName } ` , body : message . body } ; } }
Transforms a CloudWatch message into a format appropriate for submitting to a Scalyr API endpoint (either uploadLogs
 or addEvents).
Transforms a CloudWatch message into a format appropriate for submitting to a Scalyr API endpoint ( either uploadLogs or addEvents ) .