diff options
author | Saturneric <[email protected]> | 2023-02-03 13:43:55 +0000 |
---|---|---|
committer | Saturneric <[email protected]> | 2023-02-03 13:43:55 +0000 |
commit | 11d32517c2f6f538209c893c6b0b24572fba1a36 (patch) | |
tree | 0dac14bcad75d9c7c5b5723dc23e6409721966b4 /src/ui/struct/SettingsObject.cpp | |
parent | feat: change logging framework to spdlog (diff) | |
download | GpgFrontend-11d32517c2f6f538209c893c6b0b24572fba1a36.tar.gz GpgFrontend-11d32517c2f6f538209c893c6b0b24572fba1a36.zip |
feat: change the log style in source files
Diffstat (limited to 'src/ui/struct/SettingsObject.cpp')
-rw-r--r-- | src/ui/struct/SettingsObject.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/ui/struct/SettingsObject.cpp b/src/ui/struct/SettingsObject.cpp index 4a9aa7d6..f2fb4820 100644 --- a/src/ui/struct/SettingsObject.cpp +++ b/src/ui/struct/SettingsObject.cpp @@ -32,7 +32,7 @@ nlohmann::json& GpgFrontend::UI::SettingsObject::Check( const std::string& key, const nlohmann::json& default_value) { // check if the self null if (this->nlohmann::json::is_null()) { - LOG(INFO) << "SettingsObject is null, creating new one"; + SPDLOG_INFO("settings object is null, creating new one"); this->nlohmann::json::operator=(nlohmann::json::object()); } @@ -41,9 +41,9 @@ nlohmann::json& GpgFrontend::UI::SettingsObject::Check( this->nlohmann::json::at(key).is_null() || this->nlohmann::json::at(key).type_name() != default_value.type_name()) { - LOG(INFO) << "Added missing key: " << key; + SPDLOG_INFO("added missing key: {}", key); if (default_value.is_null()) { - LOG(WARNING) << "Default value is null, using empty object"; + SPDLOG_WARN("default value is null, using empty object"); this->nlohmann::json::operator[](key) = nlohmann::json::object(); } else { this->nlohmann::json::operator[](key) = default_value; @@ -51,7 +51,7 @@ nlohmann::json& GpgFrontend::UI::SettingsObject::Check( } return this->nlohmann::json::at(key); } catch (nlohmann::json::exception& e) { - LOG(ERROR) << e.what(); + SPDLOG_ERROR(e.what()); throw e; } } @@ -60,14 +60,14 @@ GpgFrontend::UI::SettingsObject GpgFrontend::UI::SettingsObject::Check( const std::string& key) { // check if the self null if (this->nlohmann::json::is_null()) { - LOG(INFO) << "SettingsObject is null, creating new one"; + SPDLOG_INFO("settings object is null, creating new one"); this->nlohmann::json::operator=(nlohmann::json::object()); } if (!nlohmann::json::contains(key) || this->nlohmann::json::at(key).is_null() || this->nlohmann::json::at(key).type() != nlohmann::json::value_t::object) { - LOG(INFO) << "Added missing key: " << key; + SPDLOG_INFO("added missing key: {}", key); this->nlohmann::json::operator[](key) = nlohmann::json::object(); } return SettingsObject{nlohmann::json::operator[](key), false}; @@ -76,21 +76,21 @@ GpgFrontend::UI::SettingsObject GpgFrontend::UI::SettingsObject::Check( GpgFrontend::UI::SettingsObject::SettingsObject(std::string settings_name) : settings_name_(std::move(settings_name)) { try { - LOG(INFO) << "Loading settings from: " << this->settings_name_; + SPDLOG_INFO("loading settings from: {}", this->settings_name_); auto _json_optional = GpgFrontend::DataObjectOperator::GetInstance().GetDataObject( settings_name_); if (_json_optional.has_value()) { - LOG(INFO) << "SettingsObject: " << settings_name_ << " loaded."; + SPDLOG_INFO("settings object: {} loaded.", settings_name_); nlohmann::json::operator=(_json_optional.value()); } else { - LOG(INFO) << "SettingsObject: " << settings_name_ << " not found."; + SPDLOG_INFO("settings object: {} not found.", settings_name_); nlohmann::json::operator=({}); } } catch (std::exception& e) { - LOG(ERROR) << e.what(); + SPDLOG_ERROR(e.what()); } } @@ -101,4 +101,4 @@ GpgFrontend::UI::SettingsObject::~SettingsObject() { if (!settings_name_.empty()) GpgFrontend::DataObjectOperator::GetInstance().SaveDataObj(settings_name_, *this); -} +}
\ No newline at end of file |