1 /*
2 * Copyright (c) 2021 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 /* This files contains faultlog config modules. */
17
18 #include "fault_logger_config.h"
19
20 #include <string>
21 #include "dfx_log.h"
22
23 namespace OHOS {
24 namespace HiviewDFX {
25 namespace {
26 static const std::string FAULTLOGGER_CONFIG_TAG = "FaultLoggerConfig";
27 }
28
FaultLoggerConfig(const int number,const long size,const std::string & path,const std::string & debugPath)29 FaultLoggerConfig::FaultLoggerConfig(const int number, const long size, const std::string& path, const std::string& debugPath)
30 :logFileNumber_(number), logFileSize_(size), logFilePath_(path), debugLogFilePath_(debugPath)
31 {
32 DfxLogDebug("%s :: %d, %ld, %s, %s.",
33 FAULTLOGGER_CONFIG_TAG.c_str(), number, size, path.c_str(), debugPath.c_str());
34 }
35
~FaultLoggerConfig()36 FaultLoggerConfig::~FaultLoggerConfig()
37 {
38 }
39
GetLogFileMaxNumber() const40 int FaultLoggerConfig::GetLogFileMaxNumber() const
41 {
42 DfxLogDebug("%s :: GetLogFileMaxNumber(%d).",
43 FAULTLOGGER_CONFIG_TAG.c_str(), logFileNumber_);
44 return logFileNumber_;
45 }
46
SetLogFileMaxNumber(const int number)47 bool FaultLoggerConfig::SetLogFileMaxNumber(const int number)
48 {
49 logFileNumber_ = number;
50 DfxLogDebug("%s :: SetLogFileMaxNumber(%d).",
51 FAULTLOGGER_CONFIG_TAG.c_str(), logFileNumber_);
52 return true;
53 }
54
GetLogFileMaxSize() const55 long FaultLoggerConfig::GetLogFileMaxSize() const
56 {
57 DfxLogDebug("%s :: GetLogFileMaxSize(%ld).",
58 FAULTLOGGER_CONFIG_TAG.c_str(), logFileSize_);
59 return logFileSize_;
60 }
61
SetLogFileMaxSize(const long size)62 bool FaultLoggerConfig::SetLogFileMaxSize(const long size)
63 {
64 logFileSize_ = size;
65 DfxLogDebug("%s :: SetLogFileMaxSize(%ld).",
66 FAULTLOGGER_CONFIG_TAG.c_str(), logFileSize_);
67 return true;
68 }
69
GetLogFilePath() const70 std::string FaultLoggerConfig::GetLogFilePath() const
71 {
72 DfxLogDebug("%s :: GetLogFilePath(%s).",
73 FAULTLOGGER_CONFIG_TAG.c_str(), logFilePath_.c_str());
74 return logFilePath_;
75 }
76
SetLogFilePath(const std::string & path)77 bool FaultLoggerConfig::SetLogFilePath(const std::string& path)
78 {
79 logFilePath_ = path;
80 DfxLogDebug("%s :: SetLogFilePath(%s).",
81 FAULTLOGGER_CONFIG_TAG.c_str(), logFilePath_.c_str());
82 return true;
83 }
84
GetDebugLogFilePath() const85 std::string FaultLoggerConfig::GetDebugLogFilePath() const
86 {
87 DfxLogDebug("%s :: GetDebugLogFilePath(%s).",
88 FAULTLOGGER_CONFIG_TAG.c_str(), debugLogFilePath_.c_str());
89 return debugLogFilePath_;
90 }
91
SetDebugLogFilePath(const std::string & path)92 bool FaultLoggerConfig::SetDebugLogFilePath(const std::string& path)
93 {
94 debugLogFilePath_ = path;
95 DfxLogDebug("%s :: SetDebugLogFilePath(%s).",
96 FAULTLOGGER_CONFIG_TAG.c_str(), debugLogFilePath_.c_str());
97 return true;
98 }
99 } // namespace HiviewDFX
100 } // namespace OHOS
101