1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef RESOURCE_SCHEDULE_SERVICE_RESSCHED_COMMON_BATCH_LOG_PRINTER_H 17 #define RESOURCE_SCHEDULE_SERVICE_RESSCHED_COMMON_BATCH_LOG_PRINTER_H 18 19 #include <string> 20 #include <unistd.h> 21 22 #include "ffrt.h" 23 #include "single_instance.h" 24 25 namespace OHOS { 26 namespace ResourceSchedule { 27 class BatchLogPrinter { 28 DECLARE_SINGLE_INSTANCE_BASE(BatchLogPrinter); 29 public: 30 BatchLogPrinter(); 31 void SubmitLog(const std::string& log); 32 private: 33 void RecordLog(const std::string& log, const int64_t& timestamp); 34 void GetBatch(std::vector<std::string>& batchLogs); 35 std::shared_ptr<ffrt::queue> logQueue_; 36 std::vector<std::string> allLogs_; 37 int64_t lastPrintTimestamp_; 38 }; 39 } // namespace ResourceSchedule 40 } // namespace OHOS 41 #endif // RESOURCE_SCHEDULE_SERVICE_RESSCHED_COMMON_BATCH_LOG_PRINTER_H 42