1800b99b8Sopenharmony_ci/* 2800b99b8Sopenharmony_ci * Copyright (c) 2021-2023 Huawei Device Co., Ltd. 3800b99b8Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4800b99b8Sopenharmony_ci * you may not use this file except in compliance with the License. 5800b99b8Sopenharmony_ci * You may obtain a copy of the License at 6800b99b8Sopenharmony_ci * 7800b99b8Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8800b99b8Sopenharmony_ci * 9800b99b8Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10800b99b8Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11800b99b8Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12800b99b8Sopenharmony_ci * See the License for the specific language governing permissions and 13800b99b8Sopenharmony_ci * limitations under the License. 14800b99b8Sopenharmony_ci */ 15800b99b8Sopenharmony_ci 16800b99b8Sopenharmony_ci#include "fault_logger_config.h" 17800b99b8Sopenharmony_ci 18800b99b8Sopenharmony_ci#include <string> 19800b99b8Sopenharmony_ci#include "dfx_log.h" 20800b99b8Sopenharmony_ci 21800b99b8Sopenharmony_cinamespace OHOS { 22800b99b8Sopenharmony_cinamespace HiviewDFX { 23800b99b8Sopenharmony_cinamespace { 24800b99b8Sopenharmony_cistatic const std::string FAULTLOGGER_CONFIG_TAG = "FaultLoggerConfig"; 25800b99b8Sopenharmony_ci} 26800b99b8Sopenharmony_ci 27800b99b8Sopenharmony_ciFaultLoggerConfig::FaultLoggerConfig(const int number, const long size, 28800b99b8Sopenharmony_ci const std::string& path, const std::string& debugPath) 29800b99b8Sopenharmony_ci :logFileNumber_(number), logFileSize_(size), logFilePath_(path), debugLogFilePath_(debugPath) 30800b99b8Sopenharmony_ci{ 31800b99b8Sopenharmony_ci DFXLOGD("%{public}s :: %{public}d, %{public}ld, %{public}s, %{public}s.", 32800b99b8Sopenharmony_ci FAULTLOGGER_CONFIG_TAG.c_str(), number, size, path.c_str(), debugPath.c_str()); 33800b99b8Sopenharmony_ci} 34800b99b8Sopenharmony_ci 35800b99b8Sopenharmony_ciFaultLoggerConfig::~FaultLoggerConfig() 36800b99b8Sopenharmony_ci{ 37800b99b8Sopenharmony_ci} 38800b99b8Sopenharmony_ci 39800b99b8Sopenharmony_ciint FaultLoggerConfig::GetLogFileMaxNumber() const 40800b99b8Sopenharmony_ci{ 41800b99b8Sopenharmony_ci DFXLOGD("%{public}s :: GetLogFileMaxNumber(%{public}d).", 42800b99b8Sopenharmony_ci FAULTLOGGER_CONFIG_TAG.c_str(), logFileNumber_); 43800b99b8Sopenharmony_ci return logFileNumber_; 44800b99b8Sopenharmony_ci} 45800b99b8Sopenharmony_ci 46800b99b8Sopenharmony_cibool FaultLoggerConfig::SetLogFileMaxNumber(const int number) 47800b99b8Sopenharmony_ci{ 48800b99b8Sopenharmony_ci logFileNumber_ = number; 49800b99b8Sopenharmony_ci DFXLOGD("%{public}s :: SetLogFileMaxNumber(%{public}d).", 50800b99b8Sopenharmony_ci FAULTLOGGER_CONFIG_TAG.c_str(), logFileNumber_); 51800b99b8Sopenharmony_ci return true; 52800b99b8Sopenharmony_ci} 53800b99b8Sopenharmony_ci 54800b99b8Sopenharmony_cilong FaultLoggerConfig::GetLogFileMaxSize() const 55800b99b8Sopenharmony_ci{ 56800b99b8Sopenharmony_ci DFXLOGD("%{public}s :: GetLogFileMaxSize(%{public}ld).", 57800b99b8Sopenharmony_ci FAULTLOGGER_CONFIG_TAG.c_str(), logFileSize_); 58800b99b8Sopenharmony_ci return logFileSize_; 59800b99b8Sopenharmony_ci} 60800b99b8Sopenharmony_ci 61800b99b8Sopenharmony_cibool FaultLoggerConfig::SetLogFileMaxSize(const long size) 62800b99b8Sopenharmony_ci{ 63800b99b8Sopenharmony_ci logFileSize_ = size; 64800b99b8Sopenharmony_ci DFXLOGD("%{public}s :: SetLogFileMaxSize(%{public}ld).", 65800b99b8Sopenharmony_ci FAULTLOGGER_CONFIG_TAG.c_str(), logFileSize_); 66800b99b8Sopenharmony_ci return true; 67800b99b8Sopenharmony_ci} 68800b99b8Sopenharmony_ci 69800b99b8Sopenharmony_cistd::string FaultLoggerConfig::GetLogFilePath() const 70800b99b8Sopenharmony_ci{ 71800b99b8Sopenharmony_ci DFXLOGD("%{public}s :: GetLogFilePath(%{public}s).", 72800b99b8Sopenharmony_ci FAULTLOGGER_CONFIG_TAG.c_str(), logFilePath_.c_str()); 73800b99b8Sopenharmony_ci return logFilePath_; 74800b99b8Sopenharmony_ci} 75800b99b8Sopenharmony_ci 76800b99b8Sopenharmony_cibool FaultLoggerConfig::SetLogFilePath(const std::string& path) 77800b99b8Sopenharmony_ci{ 78800b99b8Sopenharmony_ci logFilePath_ = path; 79800b99b8Sopenharmony_ci DFXLOGD("%{public}s :: SetLogFilePath(%{public}s).", 80800b99b8Sopenharmony_ci FAULTLOGGER_CONFIG_TAG.c_str(), logFilePath_.c_str()); 81800b99b8Sopenharmony_ci return true; 82800b99b8Sopenharmony_ci} 83800b99b8Sopenharmony_ci} // namespace HiviewDFX 84800b99b8Sopenharmony_ci} // namespace OHOS 85