1049e185fSopenharmony_ci/* 2049e185fSopenharmony_ci * Copyright (C) 2022 Huawei Device Co., Ltd. 3049e185fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4049e185fSopenharmony_ci * you may not use this file except in compliance with the License. 5049e185fSopenharmony_ci * You may obtain a copy of the License at 6049e185fSopenharmony_ci * 7049e185fSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8049e185fSopenharmony_ci * 9049e185fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10049e185fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11049e185fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12049e185fSopenharmony_ci * See the License for the specific language governing permissions and 13049e185fSopenharmony_ci * limitations under the License. 14049e185fSopenharmony_ci */ 15049e185fSopenharmony_ci#ifndef DFX_LOG_DUMP_H 16049e185fSopenharmony_ci#define DFX_LOG_DUMP_H 17049e185fSopenharmony_ci 18049e185fSopenharmony_ci#include <string> 19049e185fSopenharmony_ci#include <hilog/log.h> 20049e185fSopenharmony_ci#include <thread> 21049e185fSopenharmony_ci#include <mutex> 22049e185fSopenharmony_ci 23049e185fSopenharmony_cinamespace OHOS { 24049e185fSopenharmony_cinamespace Media { 25049e185fSopenharmony_ciclass __attribute__((visibility("default"))) DfxLogDump { 26049e185fSopenharmony_cipublic: 27049e185fSopenharmony_ci static DfxLogDump &GetInstance(); 28049e185fSopenharmony_ci void SaveLog(const char *level, const OHOS::HiviewDFX::HiLogLabel &label, const char *fmt, ...); 29049e185fSopenharmony_ci 30049e185fSopenharmony_ciprivate: 31049e185fSopenharmony_ci DfxLogDump(); 32049e185fSopenharmony_ci ~DfxLogDump(); 33049e185fSopenharmony_ci void UpdateCheckEnable(); 34049e185fSopenharmony_ci int32_t fileCount_ = 0; 35049e185fSopenharmony_ci int32_t lineCount_ = 0; 36049e185fSopenharmony_ci std::unique_ptr<std::thread> thread_; 37049e185fSopenharmony_ci void TaskProcessor(); 38049e185fSopenharmony_ci std::mutex mutex_; 39049e185fSopenharmony_ci std::condition_variable cond_; 40049e185fSopenharmony_ci std::string logString_; 41049e185fSopenharmony_ci bool isDump_ = false; 42049e185fSopenharmony_ci bool isExit_ = false; 43049e185fSopenharmony_ci bool isEnable_ = false; 44049e185fSopenharmony_ci bool isNewFile_ = true; 45049e185fSopenharmony_ci}; 46049e185fSopenharmony_ci} // namespace Media 47049e185fSopenharmony_ci} // namespace OHOS 48049e185fSopenharmony_ci 49049e185fSopenharmony_ci#endif