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, const std::string& path, const std::string& debugPath)
28 :logFileNumber_(number), logFileSize_(size), logFilePath_(path), debugLogFilePath_(debugPath)
29 {
30 DFXLOG_DEBUG("%s :: %d, %ld, %s, %s.",
31 FAULTLOGGER_CONFIG_TAG.c_str(), number, size, path.c_str(), debugPath.c_str());
32 }
33
~FaultLoggerConfig()34 FaultLoggerConfig::~FaultLoggerConfig()
35 {
36 }
37
GetLogFileMaxNumber() const38 int FaultLoggerConfig::GetLogFileMaxNumber() const
39 {
40 DFXLOG_DEBUG("%s :: GetLogFileMaxNumber(%d).",
41 FAULTLOGGER_CONFIG_TAG.c_str(), logFileNumber_);
42 return logFileNumber_;
43 }
44
SetLogFileMaxNumber(const int number)45 bool FaultLoggerConfig::SetLogFileMaxNumber(const int number)
46 {
47 logFileNumber_ = number;
48 DFXLOG_DEBUG("%s :: SetLogFileMaxNumber(%d).",
49 FAULTLOGGER_CONFIG_TAG.c_str(), logFileNumber_);
50 return true;
51 }
52
GetLogFileMaxSize() const53 long FaultLoggerConfig::GetLogFileMaxSize() const
54 {
55 DFXLOG_DEBUG("%s :: GetLogFileMaxSize(%ld).",
56 FAULTLOGGER_CONFIG_TAG.c_str(), logFileSize_);
57 return logFileSize_;
58 }
59
SetLogFileMaxSize(const long size)60 bool FaultLoggerConfig::SetLogFileMaxSize(const long size)
61 {
62 logFileSize_ = size;
63 DFXLOG_DEBUG("%s :: SetLogFileMaxSize(%ld).",
64 FAULTLOGGER_CONFIG_TAG.c_str(), logFileSize_);
65 return true;
66 }
67
GetLogFilePath() const68 std::string FaultLoggerConfig::GetLogFilePath() const
69 {
70 DFXLOG_DEBUG("%s :: GetLogFilePath(%s).",
71 FAULTLOGGER_CONFIG_TAG.c_str(), logFilePath_.c_str());
72 return logFilePath_;
73 }
74
SetLogFilePath(const std::string & path)75 bool FaultLoggerConfig::SetLogFilePath(const std::string& path)
76 {
77 logFilePath_ = path;
78 DFXLOG_DEBUG("%s :: SetLogFilePath(%s).",
79 FAULTLOGGER_CONFIG_TAG.c_str(), logFilePath_.c_str());
80 return true;
81 }
82
GetDebugLogFilePath() const83 std::string FaultLoggerConfig::GetDebugLogFilePath() const
84 {
85 DFXLOG_DEBUG("%s :: GetDebugLogFilePath(%s).",
86 FAULTLOGGER_CONFIG_TAG.c_str(), debugLogFilePath_.c_str());
87 return debugLogFilePath_;
88 }
89
SetDebugLogFilePath(const std::string & path)90 bool FaultLoggerConfig::SetDebugLogFilePath(const std::string& path)
91 {
92 debugLogFilePath_ = path;
93 DFXLOG_DEBUG("%s :: SetDebugLogFilePath(%s).",
94 FAULTLOGGER_CONFIG_TAG.c_str(), debugLogFilePath_.c_str());
95 return true;
96 }
97 } // namespace HiviewDFX
98 } // namespace OHOS
99