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 #include "fault_logger_config.h"
17
18 #include <string>
19 #include "dfx_log.h"
20
21 namespace OHOS {
22 namespace HiviewDFX {
23 namespace {
24 static const std::string FAULTLOGGER_CONFIG_TAG = "FaultLoggerConfig";
25 }
26
FaultLoggerConfig(const int number, const long size, const std::string& path, const std::string& debugPath)27 FaultLoggerConfig::FaultLoggerConfig(const int number, const long size,
28 const std::string& path, const std::string& debugPath)
29 :logFileNumber_(number), logFileSize_(size), logFilePath_(path), debugLogFilePath_(debugPath)
30 {
31 DFXLOGD("%{public}s :: %{public}d, %{public}ld, %{public}s, %{public}s.",
32 FAULTLOGGER_CONFIG_TAG.c_str(), number, size, path.c_str(), debugPath.c_str());
33 }
34
~FaultLoggerConfig()35 FaultLoggerConfig::~FaultLoggerConfig()
36 {
37 }
38
GetLogFileMaxNumber() const39 int FaultLoggerConfig::GetLogFileMaxNumber() const
40 {
41 DFXLOGD("%{public}s :: GetLogFileMaxNumber(%{public}d).",
42 FAULTLOGGER_CONFIG_TAG.c_str(), logFileNumber_);
43 return logFileNumber_;
44 }
45
SetLogFileMaxNumber(const int number)46 bool FaultLoggerConfig::SetLogFileMaxNumber(const int number)
47 {
48 logFileNumber_ = number;
49 DFXLOGD("%{public}s :: SetLogFileMaxNumber(%{public}d).",
50 FAULTLOGGER_CONFIG_TAG.c_str(), logFileNumber_);
51 return true;
52 }
53
GetLogFileMaxSize() const54 long FaultLoggerConfig::GetLogFileMaxSize() const
55 {
56 DFXLOGD("%{public}s :: GetLogFileMaxSize(%{public}ld).",
57 FAULTLOGGER_CONFIG_TAG.c_str(), logFileSize_);
58 return logFileSize_;
59 }
60
SetLogFileMaxSize(const long size)61 bool FaultLoggerConfig::SetLogFileMaxSize(const long size)
62 {
63 logFileSize_ = size;
64 DFXLOGD("%{public}s :: SetLogFileMaxSize(%{public}ld).",
65 FAULTLOGGER_CONFIG_TAG.c_str(), logFileSize_);
66 return true;
67 }
68
GetLogFilePath() const69 std::string FaultLoggerConfig::GetLogFilePath() const
70 {
71 DFXLOGD("%{public}s :: GetLogFilePath(%{public}s).",
72 FAULTLOGGER_CONFIG_TAG.c_str(), logFilePath_.c_str());
73 return logFilePath_;
74 }
75
SetLogFilePath(const std::string& path)76 bool FaultLoggerConfig::SetLogFilePath(const std::string& path)
77 {
78 logFilePath_ = path;
79 DFXLOGD("%{public}s :: SetLogFilePath(%{public}s).",
80 FAULTLOGGER_CONFIG_TAG.c_str(), logFilePath_.c_str());
81 return true;
82 }
83 } // namespace HiviewDFX
84 } // namespace OHOS
85