1 /*
2  * Copyright (C) 2022 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 #ifndef DFX_LOG_DUMP_H
16 #define DFX_LOG_DUMP_H
17 
18 #include <string>
19 #include <hilog/log.h>
20 #include <thread>
21 #include <mutex>
22 
23 namespace OHOS {
24 namespace Media {
25 class __attribute__((visibility("default"))) DfxLogDump {
26 public:
27     static DfxLogDump &GetInstance();
28     void SaveLog(const char *level, const OHOS::HiviewDFX::HiLogLabel &label, const char *fmt, ...);
29 
30 private:
31     DfxLogDump();
32     ~DfxLogDump();
33     void UpdateCheckEnable();
34     int32_t fileCount_ = 0;
35     int32_t lineCount_ = 0;
36     std::unique_ptr<std::thread> thread_;
37     void TaskProcessor();
38     std::mutex mutex_;
39     std::condition_variable cond_;
40     std::string logString_;
41     bool isDump_ = false;
42     bool isExit_ = false;
43     bool isEnable_ = false;
44     bool isNewFile_ = true;
45 };
46 } // namespace Media
47 } // namespace OHOS
48 
49 #endif