17 #include <aws/core/Aws.h> 18 #include <aws/core/utils/logging/LogMacros.h> 19 #include <aws/logs/CloudWatchLogsClient.h> 20 #include <aws/logs/model/PutLogEventsRequest.h> 37 namespace CloudWatchLogs {
42 const std::string & log_group,
43 const std::string & log_stream,
44 const Aws::Client::ClientConfiguration & client_config)
55 const std::string & log_group,
56 const std::string & log_stream,
57 std::shared_ptr<Aws::CloudWatchLogs::Utils::CloudWatchLogsFacade> cloudwatch_facade)
86 AWS_LOGSTREAM_DEBUG(__func__,
"CheckLogGroupExists code:" << status);
91 AWS_LOGSTREAM_DEBUG(__func__,
"Found existing log group: " <<
log_group_);
104 AWS_LOGSTREAM_DEBUG(__func__,
"Successfully created log group.");
110 AWS_LOGSTREAM_INFO(__func__,
"Log group already exists.");
115 AWS_LOGSTREAM_ERROR(__func__,
"Failed to create log group, status: " 134 AWS_LOGSTREAM_DEBUG(__func__,
"Found existing log stream: " << this->
log_stream_);
145 AWS_LOG_DEBUG(__func__,
"Successfully created log stream.");
149 AWS_LOG_DEBUG(__func__,
"Log stream already exists");
153 AWS_LOGSTREAM_ERROR(__func__,
"Failed to create log stream, status: " 173 AWS_LOG_DEBUG(__func__,
"Get Token succeeded");
177 AWS_LOGSTREAM_ERROR(__func__,
"Unable to obtain the sequence token to use, status: " 186 AWS_LOG_DEBUG(__func__,
187 "Attempting to use logs of size %i", data.size());
194 AWS_LOG_INFO(__func__,
"Sending logs to CW");
196 if (!std::ifstream(
"/tmp/internet").good()) {
199 AWS_LOG_DEBUG(__func__,
"SendLogs status=%d", send_logs_status);
203 AWS_LOG_WARN(__func__,
"Unable to send logs to CloudWatch, retrying ...");
208 AWS_LOG_WARN(__func__,
209 "Unable to obtain the sequence token to use");
218 "Unable to send logs to CloudWatch");
221 AWS_LOG_DEBUG(__func__,
222 "Unable to obtain the sequence token to use");
226 return send_logs_status;
242 AWS_LOG_WARN(__func__,
"CreateGroup FAILED");
245 AWS_LOG_DEBUG(__func__,
"CreateGroup succeeded");
251 AWS_LOG_WARN(__func__,
"CreateStream FAILED");
254 AWS_LOG_DEBUG(__func__,
"CreateGroup succeeded");
263 AWS_LOG_WARN(__func__,
"INIT TOKEN FAILED");
266 AWS_LOG_DEBUG(__func__,
"INIT TOKEN succeeded");
277 AWS_LOG_DEBUG(__func__,
"no data to publish");
286 AWS_LOG_DEBUG(__func__,
"attempting to SendLogFiles");
295 AWS_LOG_DEBUG(__func__,
"finished SendLogs");
304 AWS_LOG_WARN(__func__,
"error finishing SendLogs %d", status);
LogPublisherRunState getRunState()
bool checkIfConnected(Aws::CloudWatchLogs::ROSCloudWatchLogsErrors error)
Aws::DataFlow::UploadStatus publishData(std::list< Aws::CloudWatchLogs::Model::InputLogEvent > &data) override
Aws::CloudWatchLogs::ROSCloudWatchLogsErrors SendLogs(Aws::String &next_token, std::list< Aws::CloudWatchLogs::Model::InputLogEvent > &data)
ObservableObject< LogPublisherRunState > run_state_
std::list< LogType > LogCollection
constexpr int kMaxRetries
virtual void setValue(const T &v)
bool InitToken(Aws::String &next_token)
Aws::Client::ClientConfiguration client_config_
Contains Error handling functionality for ROS AWS CloudWatch Logs libraries.
static const Aws::String UNINITIALIZED_TOKEN
std::shared_ptr< Aws::CloudWatchLogs::Utils::CloudWatchLogsFacade > cloudwatch_facade_
LogPublisher(const std::string &log_group, const std::string &log_stream, const Aws::Client::ClientConfiguration &client_config)
Creates a LogPublisher object that uses the provided client and SDK configuration Constructs a LogPub...
LogPublisherRunState
Defines the different runtime states for the Publisher This enum is used by the LogPublisher to track...
~LogPublisher() override
Tears down the LogPublisher object.
ROSCloudWatchLogsErrors
Defines error return codes for functions This enum defines standard error codes that will be returned...