Aws::DataFlow::UploadStatus LogPublisher::publishData()

in cloudwatch_logs_common/src/log_publisher.cpp [272:307]


Aws::DataFlow::UploadStatus LogPublisher::publishData(LogCollection & data)
{

  // if no data don't attempt to configure or publish
  if (data.empty()) {
    AWS_LOG_DEBUG(__func__, "no data to publish");
    return Aws::DataFlow::INVALID_DATA;
  }

  // attempt to configure (if needed, based on run_state_)
  if (!configure()) {
    return Aws::DataFlow::FAIL;
  }

  AWS_LOG_DEBUG(__func__, "attempting to SendLogFiles");

  // all config succeeded: attempt to publish
  this->run_state_.setValue(LOG_PUBLISHER_ATTEMPT_SEND_LOGS);
  auto status = SendLogs(next_token, data);

  // if failed attempt to get the token next time
  // otherwise everything succeeded to attempt to send logs again
  this->run_state_.setValue(status == CW_LOGS_SUCCEEDED ? LOG_PUBLISHER_ATTEMPT_SEND_LOGS : LOG_PUBLISHER_RUN_INIT_TOKEN);
  AWS_LOG_DEBUG(__func__, "finished SendLogs");

  switch(status) {

    case CW_LOGS_SUCCEEDED:
      return Aws::DataFlow::SUCCESS;
    case CW_LOGS_INVALID_PARAMETER:
      return Aws::DataFlow::INVALID_DATA;
    default:
      AWS_LOG_WARN(__func__, "error finishing SendLogs %d", status);
      return Aws::DataFlow::FAIL;
  }
}