log_node.h
Go to the documentation of this file.
1 /*
2  * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 #pragma once
17 
23 #include <ros/ros.h>
24 #include <rosgraph_msgs/Log.h>
25 #include <unordered_set>
26 #include <std_srvs/Trigger.h>
27 #include <std_srvs/Empty.h>
28 
29 namespace Aws {
30 namespace CloudWatchLogs {
31 namespace Utils {
32 
33 class LogNode : public Service
34 {
35 public:
36  struct Options {
37  Options() = default;
38 
39  template<class UnorderedSet>
40  Options(int8_t severity, bool publish, UnorderedSet && nodes)
41  : min_log_severity(severity),
42  publish_topic_names(publish),
43  ignore_nodes(std::forward<UnorderedSet>(nodes)) {}
44 
45  int8_t min_log_severity = rosgraph_msgs::Log::DEBUG;
46  bool publish_topic_names = true;
47  std::unordered_set<std::string> ignore_nodes;
48  };
49 
55  explicit LogNode(const Options & options);
56 
64  explicit LogNode(int8_t min_log_severity, std::unordered_set<std::string> ignore_nodes);
65 
66  LogNode(const LogNode & other) = delete;
67 
68  LogNode & operator=(const LogNode & other) = delete;
69 
73  ~LogNode() override;
74 
84  void Initialize(const std::string & log_group, const std::string & log_stream,
85  const Aws::Client::ClientConfiguration & config, Aws::SDKOptions & sdk_options,
86  const Aws::CloudWatchLogs::CloudWatchOptions & cloudwatch_options,
87  const std::shared_ptr<LogServiceFactory>& log_service_factory = std::make_shared<LogServiceFactory>());
88 
89  bool start() override;
90  bool shutdown() override;
91 
97  void RecordLogs(const rosgraph_msgs::Log::ConstPtr & log_msg);
98 
105  void TriggerLogPublisher(const ros::TimerEvent & /*unused*/);
106 
114  bool checkIfOnline(std_srvs::Trigger::Request& request, std_srvs::Trigger::Response& response);
115 
116 private:
117  bool ShouldSendToCloudWatchLogs(const int8_t log_severity_level);
118  const std::string FormatLogs(const rosgraph_msgs::Log::ConstPtr & log_msg);
119 
120  std::shared_ptr<Aws::CloudWatchLogs::LogService> log_service_;
122  std::unordered_set<std::string> ignore_nodes_;
124 };
125 
126 } // namespace Utils
127 } // namespace CloudWatchLogs
128 } // namespace Aws
~LogNode() override
Tears down a AWSCloudWatchLogNode object.
Definition: log_node.cpp:44
LogNode(const Options &options)
Definition: log_node.cpp:36
bool checkIfOnline(std_srvs::Trigger::Request &request, std_srvs::Trigger::Response &response)
Definition: log_node.cpp:54
const std::string FormatLogs(const rosgraph_msgs::Log::ConstPtr &log_msg)
Definition: log_node.cpp:111
std::unordered_set< std::string > ignore_nodes_
Definition: log_node.h:122
void TriggerLogPublisher(const ros::TimerEvent &)
Trigger the log manager to call its Service function to publish logs to cloudwatch periodically...
Definition: log_node.cpp:102
void RecordLogs(const rosgraph_msgs::Log::ConstPtr &log_msg)
Emits RecordLog using the log manager.
Definition: log_node.cpp:87
bool ShouldSendToCloudWatchLogs(const int8_t log_severity_level)
Definition: log_node.cpp:106
std::unordered_set< std::string > ignore_nodes
Definition: log_node.h:47
Options(int8_t severity, bool publish, UnorderedSet &&nodes)
Definition: log_node.h:40
std::shared_ptr< Aws::CloudWatchLogs::LogService > log_service_
Definition: log_node.h:120
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.
Definition: log_node.cpp:46
LogNode & operator=(const LogNode &other)=delete


cloudwatch_logger
Author(s): AWS RoboMaker
autogenerated on Sat Mar 6 2021 03:55:46