log_file_manager.h
Go to the documentation of this file.
1 /*
2  * Copyright 2019 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 #include <queue>
18 #include <tuple>
19 #include <aws/logs/model/InputLogEvent.h>
20 
24 
25 namespace Aws {
26 namespace CloudWatchLogs {
27 namespace Utils {
28 
29 using FileManagement::FileManager;
30 using FileManagement::FileManagerStrategy;
31 using FileManagement::FileObject;
32 
37  public FileManager<LogCollection> {
38  public:
42  LogFileManager() = default;
43 
44  // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions)
46  : FileManager(options) {
47  }
48 
49  explicit LogFileManager(const std::shared_ptr<Aws::FileManagement::DataManagerStrategy> &file_manager_strategy)
50  : FileManager(file_manager_strategy)
51  {
52  }
53 
54  ~LogFileManager() override = default;
55 
56  void write(const LogCollection & data) override;
57 
58  /*
59  AWSClient will return 'InvalidParameterException' error when the log events in a
60  single batch span more than 24 hours. Therefore the readBatch function will only
61  return as many logs as can fit within the 24 hour span and the actual number of
62  logs batched may end up being less than the original batch_size.
63 
64  We must sort the log data chronologically because it is not guaranteed
65  to be ordered chronologically in the file, but CloudWatch requires all
66  puts in a single batch to be sorted chronologically
67  */
68  FileObject<LogCollection> readBatch(size_t batch_size) override;
69 
70  using Timestamp = long;
72 };
73 
74 } // namespace Utils
75 
76  const long ONE_DAY_IN_MILLISEC = 24*60*60*1000;
78 } // namespace CloudWatchLogs
79 } // namespace Aws
void write(const LogCollection &data) override
const long TWO_WEEK_IN_MILLISEC
std::list< LogType > LogCollection
Definition: definitions.h:29
FileObject< LogCollection > readBatch(size_t batch_size) override
Contains Error handling functionality for ROS AWS CloudWatch Logs libraries.
LogFileManager(const Aws::FileManagement::FileManagerStrategyOptions &options)
const long ONE_DAY_IN_MILLISEC
LogFileManager(const std::shared_ptr< Aws::FileManagement::DataManagerStrategy > &file_manager_strategy)


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