client-cpp  0.10.0
RecordCountLogUploadStrategy.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2014-2016 CyberVision, Inc.
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  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 
18 #ifndef RECORDCOUNTLOGUPLOADSTRATEGY_HPP_
19 #define RECORDCOUNTLOGUPLOADSTRATEGY_HPP_
20 
21 #include <cstdlib>
22 
23 #include "kaa/logging/Log.hpp"
26 
27 namespace kaa {
28 
30 public:
31  RecordCountLogUploadStrategy(std::size_t countThreshold, IKaaClientContext &context)
32  : DefaultLogUploadStrategy(context)
33  {
34  setCountThreshold(countThreshold);
35  }
36 
38  {
39  auto currentRecordCount = status.getRecordsCount();
40 
41  if (currentRecordCount >= uploadCountThreshold_) {
42  KAA_LOG_INFO(boost::format("Need to upload logs - current count: %llu, threshold: %llu")
43  % currentRecordCount % uploadCountThreshold_);
45  }
46 
48  }
49 };
50 
51 }
52 
53 #endif /* RECORDCOUNTLOGUPLOADSTRATEGY_HPP_ */
RecordCountLogUploadStrategy(std::size_t countThreshold, IKaaClientContext &context)
The default ILogUploadStrategy implementation.
void setCountThreshold(std::size_t maxCount)
virtual LogUploadStrategyDecision isUploadNeeded(ILogStorageStatus &status) override
Decides whether the log upload is needed.
#define KAA_LOG_INFO(message)
Definition: Log.hpp:64
LogUploadStrategyDecision
Log upload decisions.
virtual std::size_t getRecordsCount()=0
Returns the number of collected logs.
The public interface to represent the current log storage state.