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     DFXLOG_DEBUG("%s :: %d, %ld, %s, %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     DFXLOG_DEBUG("%s :: GetLogFileMaxNumber(%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     DFXLOG_DEBUG("%s :: SetLogFileMaxNumber(%d).",
50         FAULTLOGGER_CONFIG_TAG.c_str(), logFileNumber_);
51     return true;
52 }
53 
GetLogFileMaxSize() const54 long FaultLoggerConfig::GetLogFileMaxSize() const
55 {
56     DFXLOG_DEBUG("%s :: GetLogFileMaxSize(%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     DFXLOG_DEBUG("%s :: SetLogFileMaxSize(%ld).",
65         FAULTLOGGER_CONFIG_TAG.c_str(), logFileSize_);
66     return true;
67 }
68 
GetLogFilePath() const69 std::string FaultLoggerConfig::GetLogFilePath() const
70 {
71     DFXLOG_DEBUG("%s :: GetLogFilePath(%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     DFXLOG_DEBUG("%s :: SetLogFilePath(%s).",
80         FAULTLOGGER_CONFIG_TAG.c_str(), logFilePath_.c_str());
81     return true;
82 }
83 
GetDebugLogFilePath() const84 std::string FaultLoggerConfig::GetDebugLogFilePath() const
85 {
86     DFXLOG_DEBUG("%s :: GetDebugLogFilePath(%s).",
87         FAULTLOGGER_CONFIG_TAG.c_str(), debugLogFilePath_.c_str());
88     return debugLogFilePath_;
89 }
90 
SetDebugLogFilePath(const std::string & path)91 bool FaultLoggerConfig::SetDebugLogFilePath(const std::string& path)
92 {
93     debugLogFilePath_ = path;
94     DFXLOG_DEBUG("%s :: SetDebugLogFilePath(%s).",
95         FAULTLOGGER_CONFIG_TAG.c_str(), debugLogFilePath_.c_str());
96     return true;
97 }
98 } // namespace HiviewDFX
99 } // namespace OHOS
100