in cloudwatch_logs_common/src/log_publisher.cpp [124:157]
bool LogPublisher::CreateStream()
{
Aws::CloudWatchLogs::ROSCloudWatchLogsErrors status =
this->cloudwatch_facade_->CheckLogStreamExists(this->log_group_, this->log_stream_, nullptr);
if (!checkIfConnected(status)) {
return false;
}
if (CW_LOGS_SUCCEEDED == status) {
this->run_state_.setValue(Aws::CloudWatchLogs::LOG_PUBLISHER_RUN_INIT_TOKEN);
AWS_LOGSTREAM_DEBUG(__func__, "Found existing log stream: " << this->log_stream_);
return true;
}
status = this->cloudwatch_facade_->CreateLogStream(this->log_group_, this->log_stream_);
if (!checkIfConnected(status)) {
return false;
}
if (CW_LOGS_SUCCEEDED == status) {
this->run_state_.setValue(Aws::CloudWatchLogs::LOG_PUBLISHER_RUN_INIT_TOKEN);
AWS_LOG_DEBUG(__func__, "Successfully created log stream.");
return true;
} else if (CW_LOGS_LOG_STREAM_ALREADY_EXISTS == status) {
this->run_state_.setValue(Aws::CloudWatchLogs::LOG_PUBLISHER_RUN_INIT_TOKEN);
AWS_LOG_DEBUG(__func__, "Log stream already exists");
return true;
} else {
AWS_LOGSTREAM_ERROR(__func__, "Failed to create log stream, status: "
<< status);
return false;
}
}