client-cpp  0.8.1
RecordCountLogUploadStrategy.hpp
Go to the documentation of this file.
1 
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.