16 #include <aws/core/utils/logging/AWSLogging.h> 17 #include <aws/core/utils/logging/LogMacros.h> 27 #include <rosgraph_msgs/Log.h> 28 #include <std_srvs/Trigger.h> 29 #include <std_srvs/Empty.h> 33 namespace CloudWatchLogs {
37 : min_log_severity_(options.min_log_severity),
38 ignore_nodes_(options.ignore_nodes),
39 publish_topic_names_(options.publish_topic_names) {}
41 LogNode::LogNode(int8_t min_log_severity, std::unordered_set<std::string> ignore_nodes)
47 const Aws::Client::ClientConfiguration & config, Aws::SDKOptions & sdk_options,
49 const std::shared_ptr<LogServiceFactory>& factory)
51 this->
log_service_ = factory->CreateLogService(log_group, log_stream, config, sdk_options, cloudwatch_options);
56 AWS_LOGSTREAM_DEBUG(__func__,
"received request " << request);
59 response.success =
false;
60 response.message =
"The LogService is not initialized";
65 response.message = response.success ?
"The LogService is connected" :
"The LogService is not connected";
71 bool is_started =
true;
91 AWS_LOG_ERROR(__func__,
92 "Cannot publish CloudWatch logs with NULL CloudWatch LogManager instance.");
113 std::stringstream ss;
114 ss << log_msg->header.stamp <<
" ";
116 switch (log_msg->level) {
117 case rosgraph_msgs::Log::FATAL:
120 case rosgraph_msgs::Log::ERROR:
123 case rosgraph_msgs::Log::WARN:
126 case rosgraph_msgs::Log::DEBUG:
129 case rosgraph_msgs::Log::INFO:
133 ss << log_msg->level <<
" ";
135 ss <<
"[node name: " << log_msg->name <<
"] ";
139 auto it = log_msg->topics.begin();
140 auto end = log_msg->topics.end();
141 for (; it != end; ++it) {
142 const std::string & topic = *it;
143 if (it != log_msg->topics.begin()) {
151 ss << log_msg->msg <<
"\n";
~LogNode() override
Tears down a AWSCloudWatchLogNode object.
LogNode(const Options &options)
bool checkIfOnline(std_srvs::Trigger::Request &request, std_srvs::Trigger::Response &response)
const std::string FormatLogs(const rosgraph_msgs::Log::ConstPtr &log_msg)
std::unordered_set< std::string > ignore_nodes_
void TriggerLogPublisher(const ros::TimerEvent &)
Trigger the log manager to call its Service function to publish logs to cloudwatch periodically...
void RecordLogs(const rosgraph_msgs::Log::ConstPtr &log_msg)
Emits RecordLog using the log manager.
bool ShouldSendToCloudWatchLogs(const int8_t log_severity_level)
std::shared_ptr< Aws::CloudWatchLogs::LogService > log_service_
bool publish_topic_names_
void Initialize(const std::string &log_group, const std::string &log_stream, const Aws::Client::ClientConfiguration &config, Aws::SDKOptions &sdk_options, const Aws::CloudWatchLogs::CloudWatchOptions &cloudwatch_options, const std::shared_ptr< LogServiceFactory > &log_service_factory=std::make_shared< LogServiceFactory >())
Reads creds, region, and SDK option to configure log manager.