Conditional logging destination

This commit is contained in:
Neshura 2023-12-26 04:06:38 +01:00
parent 1ae5d2b49f
commit 445b22fecd
Signed by: Neshura
GPG key ID: B6983AAA6B9A7A6C

View file

@ -16,7 +16,10 @@ impl InterfaceConfig {
let cfg: Self = match confy::load(env!("CARGO_PKG_NAME"),"interfaces") {
Ok(data) => data,
Err(e) => {
error!("[ERROR] {}", e);
match connected_to_journal() {
true => error!("[ERROR] {e}"),
false => eprintln!("[ERROR] {e}")
}
return Err(Box::new(e));
}
};
@ -75,7 +78,11 @@ impl ZoneConfig {
let entry = entry?;
let path = entry.path();
if path.is_dir() {
warn!("[WARN] Subdirectory in zones.d detected, this should not be the case");
let warn_msg = "Subdirectory in zones.d detected, this should not be the case";
match connected_to_journal() {
true => warn!("[WARN] {warn_msg}"),
false => eprintln!("[WARN] {warn_msg}"),
}
}
else {
let zone_config_path = format!("zones.d/{}", path.file_stem()
@ -84,7 +91,10 @@ impl ZoneConfig {
match confy::load(env!("CARGO_PKG_NAME"), zone_config_path.as_str()) {
Ok(data) => zone_configs.push(data),
Err(e) => {
error!("[ERROR] {}", e);
match connected_to_journal() {
true => error!("[ERROR] {e}"),
false => eprintln!("[ERROR] {e}"),
}
return Err(Box::new(e));
}
};