client-cpp  0.10.0
StorageSizeLogUploadStrategy.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 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.