• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2023 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 FAULT_LOGGER_CONFIG_H
17 #define FAULT_LOGGER_CONFIG_H
18 
19 #include <string>
20 #include <vector>
21 #include <cstdint>
22 
23 namespace OHOS {
24 namespace HiviewDFX {
25 
26 enum class OverFileSizeAction {
27     CROP = 0, // default
28     DELETE,
29 };
30 
31 enum class OverTimeFileDeleteType {
32     PASSIVE = 0, // default
33     ACTIVE,
34 };
35 
36 struct SingleFileConfig {
37     int32_t type;
38     std::string fileNamePrefix;
39     uint64_t maxSingleFileSize;
40     OverFileSizeAction overFileSizeAction;
41     int32_t fileExistTime;
42     OverTimeFileDeleteType overTimeFileDeleteType;
43     int32_t keepFileCount;
44     int32_t maxFileCount;
45 };
46 
47 struct DirectoryConfig {
48     std::string tempFilePath;
49     uint64_t maxTempFilesSize = 0;
50     int32_t fileClearTimeAfterBoot = 0;
51     std::vector<SingleFileConfig> singleFileConfigs;
52 };
53 
54 class FaultLoggerConfig {
55 public:
56     FaultLoggerConfig(const FaultLoggerConfig&) = delete;
57     FaultLoggerConfig(FaultLoggerConfig&&) = delete;
58 
59     FaultLoggerConfig &operator=(const FaultLoggerConfig&) = delete;
60     FaultLoggerConfig &operator=(FaultLoggerConfig&&) = delete;
61     static FaultLoggerConfig& GetInstance();
62     [[nodiscard]] const DirectoryConfig& GetTempFileConfig() const;
63 private:
64     FaultLoggerConfig();
65     ~FaultLoggerConfig() = default;
66     DirectoryConfig directoryConfig_{};
67 };
68 } // namespace HiviewDFX
69 } // namespace OHOS
70 
71 #endif
72