client-cpp  0.8.1
StorageSizeLogUploadStrategy.hpp
Go to the documentation of this file.
1 
18 #ifndef STORAGESIZELOGUPLOADSTRATEGY_HPP_
19 #define STORAGESIZELOGUPLOADSTRATEGY_HPP_
20 
21 #include <cstdlib>
22 
23 #include "kaa/logging/Log.hpp"
26 
27 namespace kaa {
28 
30 public:
31  StorageSizeLogUploadStrategy(std::size_t volumeThreshold, IKaaClientContext &context)
32  : DefaultLogUploadStrategy(context)
33  {
34  setVolumeThreshold(volumeThreshold);
35  }
36 
38  {
39  auto currentConsumedVolume = status.getConsumedVolume();
40 
41  if (currentConsumedVolume >= uploadVolumeThreshold_) {
42  KAA_LOG_INFO(boost::format("Need to upload logs - current size: %llu, threshold: %llu")
43  % currentConsumedVolume % uploadVolumeThreshold_);
45  }
46 
48  }
49 };
50 
51 }
52 
53 #endif /* STORAGESIZELOGUPLOADSTRATEGY_HPP_ */
virtual std::size_t getConsumedVolume()=0
Returns amount of bytes collected logs are consumed.
The default ILogUploadStrategy implementation.
virtual LogUploadStrategyDecision isUploadNeeded(ILogStorageStatus &status) override
Decides whether the log upload is needed.
void setVolumeThreshold(std::size_t maxVolume)
#define KAA_LOG_INFO(message)
Definition: Log.hpp:64
StorageSizeLogUploadStrategy(std::size_t volumeThreshold, IKaaClientContext &context)
LogUploadStrategyDecision
Log upload decisions.
The public interface to represent the current log storage state.