Skip to content

[#437] Fix misleading warning related to default config file #438

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion doc/release-notes/iceoryx2-unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
conflicts when merging.
-->

* Example text [#1](https://github.com/eclipse-iceoryx/iceoryx2/issues/1)
* Fix misleading warning related to default config file
[#437](https://github.com/eclipse-iceoryx/iceoryx2/issues/437)

### Refactoring

Expand Down
26 changes: 18 additions & 8 deletions iceoryx2/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ use iceoryx2_bb_system_types::path::Path;
use serde::{Deserialize, Serialize};
use std::time::Duration;

use iceoryx2_bb_log::{fail, trace, warn};
use iceoryx2_bb_log::{debug, fail, trace, warn};

use crate::service::port_factory::publisher::UnableToDeliverStrategy;

Expand Down Expand Up @@ -395,14 +395,24 @@ impl Config {
/// is called after this function was called, no file will be loaded since the global default
/// config was already populated.
pub fn global_config() -> &'static Config {
if !ICEORYX2_CONFIG.is_initialized()
&& Config::setup_global_config_from_file(unsafe {
if !ICEORYX2_CONFIG.is_initialized() {
match Config::setup_global_config_from_file(unsafe {
&FilePath::new_unchecked(DEFAULT_CONFIG_FILE)
})
.is_err()
{
warn!(from "Config::global_config()", "Default config file found but unable to read data, populate config with default values.");
ICEORYX2_CONFIG.set_value(Config::default());
}) {
Ok(_) => (),
Err(ConfigCreationError::FailedToOpenConfigFile) => {
debug!(from "Config::global_config()", "Default config file not found, populate config with default values.");
ICEORYX2_CONFIG.set_value(Config::default());
}
Err(ConfigCreationError::FailedToReadConfigFileContents) => {
warn!(from "Config::global_config()", "Default config file found but unable to read content, populate config with default values.");
ICEORYX2_CONFIG.set_value(Config::default());
}
Err(ConfigCreationError::UnableToDeserializeContents) => {
warn!(from "Config::global_config()", "Default config file found but unable to load data, populate config with default values.");
ICEORYX2_CONFIG.set_value(Config::default());
}
}
}

ICEORYX2_CONFIG.get()
Expand Down
Loading