log_publisher.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 
18 #include <aws/core/Aws.h>
19 #include <aws/logs/CloudWatchLogsClient.h>
21 
24 
27 
29 
30 #include <list>
31 #include <memory>
32 #include <thread>
33 
34 namespace Aws {
35 namespace CloudWatchLogs {
36 
47 };
48 
49 const static Aws::String UNINITIALIZED_TOKEN = "_NOT_SET_";
50 
54 class LogPublisher : public Publisher<LogCollection>
55 {
56 public:
64  LogPublisher(const std::string & log_group, const std::string & log_stream,
65  const Aws::Client::ClientConfiguration & client_config);
66 
75  LogPublisher(const std::string & log_group, const std::string & log_stream,
76  std::shared_ptr<Aws::CloudWatchLogs::Utils::CloudWatchLogsFacade> cw_client);
77 
78  LogPublisher(const LogPublisher & other) = delete;
79 
80  LogPublisher & operator=(const LogPublisher & other) = delete;
81 
85  ~LogPublisher() override;
86 
87  bool shutdown() override;
88 
93  bool start() override;
94 
96 
97 private:
98 
106 
110  void resetInitToken();
111 
112  //overall config
113  bool configure();
114 
115  //main publish mechanism
116  Aws::DataFlow::UploadStatus publishData(std::list<Aws::CloudWatchLogs::Model::InputLogEvent> & data) override;
117 
118  bool CreateGroup();
119  bool CreateStream();
120  bool InitToken(Aws::String & next_token);
121 
122  Aws::CloudWatchLogs::ROSCloudWatchLogsErrors SendLogs(Aws::String & next_token, std::list<Aws::CloudWatchLogs::Model::InputLogEvent> & data);
123 
124  std::shared_ptr<Aws::CloudWatchLogs::Utils::CloudWatchLogsFacade> cloudwatch_facade_;
125  Aws::SDKOptions aws_sdk_options_;
126  std::string log_group_;
127  std::string log_stream_;
128  Aws::SDKOptions options_;
129  Aws::Client::ClientConfiguration client_config_;
130 
132  Aws::String next_token;
133  mutable std::recursive_mutex mtx_;
134 };
135 
136 } // namespace CloudWatchLogs
137 } // namespace Aws
LogPublisherRunState getRunState()
LogPublisher & operator=(const LogPublisher &other)=delete
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_
bool InitToken(Aws::String &next_token)
Aws::Client::ClientConfiguration client_config_
static const Aws::String UNINITIALIZED_TOKEN
Definition: log_publisher.h:49
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...
Definition: log_publisher.h:42
~LogPublisher() override
Tears down the LogPublisher object.
ROSCloudWatchLogsErrors
Defines error return codes for functions This enum defines standard error codes that will be returned...


cloudwatch_logs_common
Author(s): AWS RoboMaker
autogenerated on Fri May 7 2021 02:18:24