log_service.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/model/InputLogEvent.h>
20 
23 
26 
29 
31 
32 #include <chrono>
33 #include <stdexcept>
34 #include <string>
35 #include <utility>
36 
37 namespace Aws {
38 namespace CloudWatchLogs {
39 
45 class LogService : public Aws::CloudWatch::CloudWatchService<std::string, LogType> {
46 public:
47 
55  LogService(std::shared_ptr<Publisher<LogCollection>> log_publisher,
56  std::shared_ptr<DataBatcher<LogType>> log_batcher,
57  std::shared_ptr<Aws::FileManagement::FileUploadStreamer<LogCollection>> log_file_upload_streamer = nullptr)
58  : CloudWatchService(std::move(log_publisher), std::move(log_batcher)) {
59 
60  this->file_upload_streamer_ = std::move(log_file_upload_streamer); // allow null, all this means is failures aren't written to file
61  }
62 
70  Aws::CloudWatchLogs::Model::InputLogEvent convertInputToBatched(
71  const std::string &input,
72  const std::chrono::milliseconds &milliseconds) override {
73 
74  Aws::CloudWatchLogs::Model::InputLogEvent log_event;
75 
76  log_event.SetMessage(input.c_str());
77  log_event.SetTimestamp(milliseconds.count());
78 
79  return log_event;
80  }
81 
88  Aws::CloudWatchLogs::Model::InputLogEvent convertInputToBatched(
89  const std::string &input) override {
90 
91  Aws::CloudWatchLogs::Model::InputLogEvent log_event;
92 
93  log_event.SetMessage(input.c_str());
94  log_event.SetTimestamp(this->getCurrentTimestamp().count());
95 
96  return log_event;
97  }
98 
99 };
100 
101 } // namespace CloudWatchLogs
102 } // namespace Aws
virtual std::chrono::milliseconds getCurrentTimestamp()
CloudWatchService(std::shared_ptr< Publisher< std::list< T >>> publisher, std::shared_ptr< DataBatcher< T >> batcher)
Aws::CloudWatchLogs::Model::InputLogEvent convertInputToBatched(const std::string &input, const std::chrono::milliseconds &milliseconds) override
Definition: log_service.h:70
std::shared_ptr< FileUploadStreamer< std::list< T > > > file_upload_streamer_
LogService(std::shared_ptr< Publisher< LogCollection >> log_publisher, std::shared_ptr< DataBatcher< LogType >> log_batcher, std::shared_ptr< Aws::FileManagement::FileUploadStreamer< LogCollection >> log_file_upload_streamer=nullptr)
Definition: log_service.h:55
Aws::CloudWatchLogs::Model::InputLogEvent convertInputToBatched(const std::string &input) override
Definition: log_service.h:88


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